Previous 15994 Revisions Next

r9786 Saturday 18th December, 2010 at 21:14:11 UTC by Nathan Woods
More global state removal. [Atari Ace]
[src/mess/devices]bitbngr.c
[src/mess/drivers]abc80x.c intv.c kaypro.c mes.c oric.c zexall.c
[src/mess/formats]m65_snqk.c
[src/mess/includes]abc80x.h gb.h intv.h kaypro.h microtan.h msx.h
[src/mess/machine]gb.c intv.c kay_kbd.c kay_kbd.h kaypro.c microtan.c msx.c x68k_hdc.c x68k_hdc.h
[src/mess/video]coco6847.c ef9345.c intv.c m6847.c microtan.c stic.c

src/mess/devices/bitbngr.c
r9785r9786
2525   int build_byte;
2626   attotime idle_delay;
2727   attotime current_baud;
28   UINT8 *input_buffer;
2928   UINT32 input_buffer_size;
3029   UINT32 input_buffer_cursor;
3130   int mode;
3231   int baud;
3332   int tune;
33   UINT8 input_buffer[1000];
3434};
3535
3636
r9785r9786
298298/*-------------------------------------------------
299299    bitbanger_bytes_to_bits_81N
300300-------------------------------------------------*/
301static void bitbanger_bytes_to_bits_81N(running_device *img, UINT8 **buffer, UINT32 *size)
301static void bitbanger_bytes_to_bits_81N(running_device *img)
302302{
303   bitbanger_token *bi = get_token(img);
303304   UINT8 byte_buffer[100];
304   static UINT8 bit_buffer[1000];
305305   UINT32 byte_buffer_size, bit_buffer_size;
306306   int i, j;
307307   static const UINT8 bitmask[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
308308
309309   bit_buffer_size = 0;
310   byte_buffer_size = 100;
311   byte_buffer_size = native_input(img, &byte_buffer, byte_buffer_size);
310   byte_buffer_size = native_input(img, byte_buffer, sizeof(byte_buffer));
312311
313312   /* Translate byte buffer into bit buffer using: 1 start bit, 8 data bits, 1 stop bit, no parity */
314313
315314   for( i=0; i<byte_buffer_size; i++ )
316315   {
317      bit_buffer[bit_buffer_size++] = 0;
316      bi->input_buffer[bit_buffer_size++] = 0;
318317
319318      for( j=0; j<8; j++ )
320319      {
321320         if( byte_buffer[i] & bitmask[j] )
322            bit_buffer[bit_buffer_size++] = 1;
321            bi->input_buffer[bit_buffer_size++] = 1;
323322         else
324            bit_buffer[bit_buffer_size++] = 0;
323            bi->input_buffer[bit_buffer_size++] = 0;
325324      }
326325
327      bit_buffer[bit_buffer_size++] = 1;
326      bi->input_buffer[bit_buffer_size++] = 1;
328327   }
329328
330   *buffer = bit_buffer;
331   *size = bit_buffer_size;
329   bi->input_buffer_size = bit_buffer_size;
330   bi->input_buffer_cursor = 0;
332331}
333332
334333
r9785r9786
347346   bi->build_count = 0;
348347   bi->bitbanger_output_timer = timer_alloc(device->machine, bitbanger_output_timer, (void *) device);
349348
350   /* input config */
349   /* input config */
351350   bi->bitbanger_input_timer = timer_alloc(device->machine, bitbanger_input_timer, (void *) device );
352   bi->idle_delay = ATTOTIME_IN_SEC(1);
353   bi->input_buffer = 0;
351   bi->idle_delay = ATTOTIME_IN_SEC(1);
354352   bi->input_buffer_size = 0;
355353   bi->input_buffer_cursor = 0;
356354
357355   bi->mode = config->default_mode;
358356   bi->baud = config->default_baud;
359357   bi->tune = config->default_tune;
360   bi->current_baud = ATTOTIME_IN_HZ(bitbanger_baud_value(device));
358   bi->current_baud = ATTOTIME_IN_HZ(bitbanger_baud_value(device));
361359
362360   /* test callback */
363361   if(!config->input_callback)
364      fatalerror("Misconfigured bitbanger device: input_callback cannot be NULL\n");
362      fatalerror("Misconfigured bitbanger device: input_callback cannot be NULL\n");
365363}
366364
367365
r9785r9786
406404   if(bi->input_buffer_cursor == bi->input_buffer_size)
407405   {
408406      /* get more data */
409      bitbanger_bytes_to_bits_81N(device, &(bi->input_buffer), &(bi->input_buffer_size));
410      bi->input_buffer_cursor = 0;
407      bitbanger_bytes_to_bits_81N(device);
411408
412409      if(bi->input_buffer_size == 0)
413410      {
r9785r9786
467464
468465static DEVICE_IMAGE_LOAD( bitbanger )
469466{
470   device_t *device = &image.device();
467   device_t *device = &image.device();
471468   bitbanger_token *bi;
472469   bi = get_token(device);
473470
474471   timer_enable(bi->bitbanger_input_timer, TRUE);
475   timer_adjust_periodic(bi->bitbanger_input_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));
472   timer_adjust_periodic(bi->bitbanger_input_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));
476473
477474   /* we don't need to do anything special */
478475   return IMAGE_INIT_PASS;
r9785r9786
485482
486483static DEVICE_IMAGE_UNLOAD( bitbanger )
487484{
488   device_t *device = &image.device();
485   device_t *device = &image.device();
489486   bitbanger_token *bi;
490487   bi = get_token(device);
491488
src/mess/machine/kay_kbd.h
r9785r9786
1UINT8 kay_kbd_c_r( void );
2UINT8 kay_kbd_d_r( void );
3void kay_kbd_d_w( running_machine *machine, UINT8 data );
4INTERRUPT_GEN( kay_kbd_interrupt );
5MACHINE_RESET( kay_kbd );
6INPUT_PORTS_EXTERN( kay_kbd );
src/mess/machine/gb.c
r9785r9786
247247   gb_state *state = machine->driver_data<gb_state>();
248248   machine->add_notifier(MACHINE_NOTIFY_EXIT, gb_machine_stop);
249249
250   state->sgb_packets = -1;
251
250252   /* Allocate the serial timer, and disable it */
251253   state->gb_serial_timer = timer_alloc(machine,  gb_serial_timer_proc , NULL);
252254   timer_enable( state->gb_serial_timer, 0 );
r9785r9786
919921WRITE8_HANDLER ( sgb_io_w )
920922{
921923   gb_state *state = space->machine->driver_data<gb_state>();
922   static UINT8 sgb_bitcount = 0, sgb_bytecount = 0, sgb_start = 0, sgb_rest = 0;
923   static UINT8 sgb_controller_no = 0, sgb_controller_mode = 0;
924   static INT8 sgb_packets = -1;
925   static UINT8 sgb_data[112];
926   static UINT32 sgb_atf;
924   UINT8 *sgb_data = state->sgb_data;
927925
928926   switch( offset )
929927   {
r9785r9786
931929         switch (data & 0x30)
932930         {
933931         case 0x00:               /* start condition */
934            if (sgb_start)
932            if (state->sgb_start)
935933               logerror("SGB: Start condition before end of transfer ??\n");
936            sgb_bitcount = 0;
937            sgb_start = 1;
938            sgb_rest = 0;
934            state->sgb_bitcount = 0;
935            state->sgb_start = 1;
936            state->sgb_rest = 0;
939937            JOYPAD = 0x0F & ((input_port_read(space->machine, "INPUTS") >> 4) | input_port_read(space->machine, "INPUTS") | 0xF0);
940938            break;
941939         case 0x10:               /* data true */
942            if (sgb_rest)
940            if (state->sgb_rest)
943941            {
944942               /* We should test for this case , but the code below won't
945943                       work with the current setup */
946944#if 0
947               if (sgb_bytecount == 16)
945               if (state->sgb_bytecount == 16)
948946               {
949947                  logerror("SGB: end of block is not zero!");
950                  sgb_start = 0;
948                  state->sgb_start = 0;
951949               }
952950#endif
953               sgb_data[sgb_bytecount] >>= 1;
954               sgb_data[sgb_bytecount] |= 0x80;
955               sgb_bitcount++;
956               if (sgb_bitcount == 8)
951               sgb_data[state->sgb_bytecount] >>= 1;
952               sgb_data[state->sgb_bytecount] |= 0x80;
953               state->sgb_bitcount++;
954               if (state->sgb_bitcount == 8)
957955               {
958                  sgb_bitcount = 0;
959                  sgb_bytecount++;
956                  state->sgb_bitcount = 0;
957                  state->sgb_bytecount++;
960958               }
961               sgb_rest = 0;
959               state->sgb_rest = 0;
962960            }
963961            JOYPAD = 0x1F & ((input_port_read(space->machine, "INPUTS") >> 4) | 0xF0);
964962            break;
965963         case 0x20:            /* data false */
966            if (sgb_rest)
964            if (state->sgb_rest)
967965            {
968               if( sgb_bytecount == 16 && sgb_packets == -1 )
966               if( state->sgb_bytecount == 16 && state->sgb_packets == -1 )
969967               {
970968#ifdef MAME_DEBUG
971969                  logerror("SGB: %s (%02X) pkts: %d data: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
r9785r9786
974972                        sgb_data[8], sgb_data[9], sgb_data[10], sgb_data[11],
975973                        sgb_data[12], sgb_data[13], sgb_data[14], sgb_data[15]);
976974#endif
977                  sgb_packets = sgb_data[0] & 0x07;
978                  sgb_start = 0;
975                  state->sgb_packets = sgb_data[0] & 0x07;
976                  state->sgb_start = 0;
979977               }
980               if (sgb_bytecount == (sgb_packets << 4) )
978               if (state->sgb_bytecount == (state->sgb_packets << 4) )
981979               {
982980                  switch( sgb_data[0] >> 3 )
983981                  {
r9785r9786
12461244                           /* Attribute File */
12471245                           if( sgb_data[9] & 0x40 )
12481246                              state->sgb_window_mask = 0;
1249                           sgb_atf = (sgb_data[9] & 0x3f) * (18 * 5);
1247                           state->sgb_atf = (sgb_data[9] & 0x3f) * (18 * 5);
12501248                           if( sgb_data[9] & 0x80 )
12511249                           {
12521250                              for( J = 0; J < 18; J++ )
12531251                              {
12541252                                 for( I = 0; I < 5; I++ )
12551253                                 {
1256                                    state->sgb_pal_map[I * 4][J] = (state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0xC0) >> 6;
1257                                    state->sgb_pal_map[(I * 4) + 1][J] = (state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0x30) >> 4;
1258                                    state->sgb_pal_map[(I * 4) + 2][J] = (state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0xC) >> 2;
1259                                    state->sgb_pal_map[(I * 4) + 3][J] = state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0x3;
1254                                    state->sgb_pal_map[I * 4][J] = (state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0xC0) >> 6;
1255                                    state->sgb_pal_map[(I * 4) + 1][J] = (state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0x30) >> 4;
1256                                    state->sgb_pal_map[(I * 4) + 2][J] = (state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0xC) >> 2;
1257                                    state->sgb_pal_map[(I * 4) + 3][J] = state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0x3;
12601258                                 }
12611259                              }
12621260                           }
r9785r9786
12911289                        break;
12921290                     case 0x11:   /* MLT_REQ - Multi controller request */
12931291                        if (sgb_data[1] == 0x00)
1294                           sgb_controller_mode = 0;
1292                           state->sgb_controller_mode = 0;
12951293                        else if (sgb_data[1] == 0x01)
1296                           sgb_controller_mode = 2;
1294                           state->sgb_controller_mode = 2;
12971295                        break;
12981296                     case 0x12:   /* JUMP */
12991297                        /* Not Implemented */
r9785r9786
13391337                           /* Attribute File */
13401338                           if( sgb_data[1] & 0x40 )
13411339                              state->sgb_window_mask = 0;
1342                           sgb_atf = (sgb_data[1] & 0x3f) * (18 * 5);
1340                           state->sgb_atf = (sgb_data[1] & 0x3f) * (18 * 5);
13431341                           for( J = 0; J < 18; J++ )
13441342                           {
13451343                              for( I = 0; I < 5; I++ )
13461344                              {
1347                                 state->sgb_pal_map[I * 4][J] = (state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0xC0) >> 6;
1348                                 state->sgb_pal_map[(I * 4) + 1][J] = (state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0x30) >> 4;
1349                                 state->sgb_pal_map[(I * 4) + 2][J] = (state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0xC) >> 2;
1350                                 state->sgb_pal_map[(I * 4) + 3][J] = state->sgb_atf_data[(J * 5) + sgb_atf + I] & 0x3;
1345                                 state->sgb_pal_map[I * 4][J] = (state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0xC0) >> 6;
1346                                 state->sgb_pal_map[(I * 4) + 1][J] = (state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0x30) >> 4;
1347                                 state->sgb_pal_map[(I * 4) + 2][J] = (state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0xC) >> 2;
1348                                 state->sgb_pal_map[(I * 4) + 3][J] = state->sgb_atf_data[(J * 5) + state->sgb_atf + I] & 0x3;
13511349                              }
13521350                           }
13531351                        }
r9785r9786
13711369                        logerror( "SGB: Unknown Command 0x%02x!\n", sgb_data[0] >> 3 );
13721370                  }
13731371
1374                  sgb_start = 0;
1375                  sgb_bytecount = 0;
1376                  sgb_packets = -1;
1372                  state->sgb_start = 0;
1373                  state->sgb_bytecount = 0;
1374                  state->sgb_packets = -1;
13771375               }
1378               if( sgb_start )
1376               if( state->sgb_start )
13791377               {
1380                  sgb_data[sgb_bytecount] >>= 1;
1381                  sgb_bitcount++;
1382                  if (sgb_bitcount == 8)
1378                  sgb_data[state->sgb_bytecount] >>= 1;
1379                  state->sgb_bitcount++;
1380                  if (state->sgb_bitcount == 8)
13831381                  {
1384                     sgb_bitcount = 0;
1385                     sgb_bytecount++;
1382                     state->sgb_bitcount = 0;
1383                     state->sgb_bytecount++;
13861384                  }
13871385               }
1388               sgb_rest = 0;
1386               state->sgb_rest = 0;
13891387            }
13901388            JOYPAD = 0x2F & (input_port_read(space->machine, "INPUTS") | 0xF0);
13911389            break;
13921390         case 0x30:               /* rest condition */
1393            if (sgb_start)
1394               sgb_rest = 1;
1395            if (sgb_controller_mode)
1391            if (state->sgb_start)
1392               state->sgb_rest = 1;
1393            if (state->sgb_controller_mode)
13961394            {
1397               sgb_controller_no++;
1398               if (sgb_controller_no == sgb_controller_mode)
1399                  sgb_controller_no = 0;
1400               JOYPAD = 0x3F - sgb_controller_no;
1395               state->sgb_controller_no++;
1396               if (state->sgb_controller_no == state->sgb_controller_mode)
1397                  state->sgb_controller_no = 0;
1398               JOYPAD = 0x3F - state->sgb_controller_no;
14011399            }
14021400            else
14031401               JOYPAD = 0x3F;
src/mess/machine/kay_kbd.c
r9785r9786
1717
1818#include "emu.h"
1919#include "sound/beep.h"
20#include "kay_kbd.h"
20#include "includes/kaypro.h"
2121
2222
2323/*
r9785r9786
5757 * producing a "clicking" sound for user feedback. Additionally, this buzzer can be activated
5858 * for a longer period by sending a 0x04 byte to the keyboard. This is used by the ROM soft
5959 * terminal to alert the user in case of a BEL.
60*
60 *
6161 * 2008-05 FP:
6262 * Small note about natural keyboard support: currently,
6363 * - "Line Feed" is mapped to the 'End' key
6464 * - "Keypad ," is not mapped
6565 */
6666
67typedef struct _kay_kbd_t
68{
69   running_device *beeper;
70   UINT8 buff[16];
71   UINT8 head;
72   UINT8 tail;
73   UINT8 beep_on;
74   UINT8 control_status;
75   UINT8 keyrows[10];
76   int lastrow;
77   int mask;
78   int key;
79   int repeat;
80   int repeater;
81} kay_kbd_t;
82
6783INPUT_PORTS_START( kay_kbd )
6884   PORT_START("ROW0")
6985   PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC)         PORT_CHAR(UCHAR_MAMEKEY(ESC))
r9785r9786
164180INPUT_PORTS_END
165181
166182static void kay_kbd_in( running_machine *machine, UINT8 data );
167static running_device *kay_kbd_beeper;
168static UINT8 kbd_buff[16];
169static UINT8 kbd_head = 0;
170static UINT8 kbd_tail = 0;
171static UINT8 beep_on = 0;
172static UINT8 control_status = 0;
173static UINT8 keyrows[10] = { 0,0,0,0,0,0,0,0,0,0 };
183
174184static const UINT8 keyboard[8][10][8] = {
175185   { /* normal */
176186      { 27,'1','2','3','4','5','6','7'},
r9785r9786
272282
273283MACHINE_RESET( kay_kbd )
274284{
285   kaypro_state *state = machine->driver_data<kaypro_state>();
286   kay_kbd_t *kbd = state->kbd = auto_alloc_clear(machine, kay_kbd_t);
287
275288   /* disable CapsLock LED initially */
276289   set_led_status(machine, 1, 1);
277290   set_led_status(machine, 1, 0);
278   kay_kbd_beeper = machine->device("beep");
279   beep_on = 1;
280   control_status = 0x14;
281   beep_set_state(kay_kbd_beeper, 0);
282   beep_set_frequency(kay_kbd_beeper, 950);   /* piezo-device needs to be measured */
283   kbd_head = kbd_tail = 0;         /* init buffer */
291   kbd->beeper = machine->device("beep");
292   kbd->beep_on = 1;
293   kbd->control_status = 0x14;
294   beep_set_state(kbd->beeper, 0);
295   beep_set_frequency(kbd->beeper, 950);   /* piezo-device needs to be measured */
296   kbd->head = kbd->tail = 0;         /* init buffer */
284297}
285298
286299/******************************************************
r9785r9786
292305 ******************************************************/
293306INTERRUPT_GEN( kay_kbd_interrupt )
294307{
308   kaypro_state *state = device->machine->driver_data<kaypro_state>();
309   kay_kbd_t *kbd = state->kbd;
295310   int mod, row, col, chg, newval;
296   static int lastrow = 0, mask = 0x00, key = 0x00, repeat = 0, repeater = 0;
311   UINT8 *keyrows = kbd->keyrows;
297312
298   if( repeat )
313   if( kbd->repeat )
299314   {
300      if( !--repeat )
301         repeater = 4;
315      if( !--kbd->repeat )
316         kbd->repeater = 4;
302317   }
303318   else
304   if( repeater )
319   if( kbd->repeater )
305320   {
306      repeat = repeater;
321      kbd->repeat = kbd->repeater;
307322   }
308323
309324   row = 9;
r9785r9786
323338
324339   if (row >= 0)
325340   {
326      repeater = 0x00;
327      mask = 0x00;
328      key = 0x00;
329      lastrow = row;
341      kbd->repeater = 0x00;
342      kbd->mask = 0x00;
343      kbd->key = 0x00;
344      kbd->lastrow = row;
330345      /* CapsLock LED */
331346      if( row == 3 && chg == 0x80 )
332         set_led_status(device->machine, 1, (keyrows[3] & 0x80) ? 0 : 1);
347         set_led_status(device->machine, 1, (kbd->keyrows[3] & 0x80) ? 0 : 1);
333348
334349      if (newval & chg)   /* key(s) pressed ? */
335350      {
r9785r9786
348363            mod |= 4;
349364
350365         /* find newval key */
351         mask = 0x01;
366         kbd->mask = 0x01;
352367         for (col = 0; col < 8; col ++)
353368         {
354            if (chg & mask)
369            if (chg & kbd->mask)
355370            {
356               newval &= mask;
357               key = keyboard[mod][row][col];
371               newval &= kbd->mask;
372               kbd->key = keyboard[mod][row][col];
358373               break;
359374            }
360            mask <<= 1;
375            kbd->mask <<= 1;
361376         }
362         if( key )   /* normal key */
377         if( kbd->key )   /* normal key */
363378         {
364            repeater = 30;
365            kay_kbd_in(device->machine, key);
379            kbd->repeater = 30;
380            kay_kbd_in(device->machine, kbd->key);
366381         }
367382         else
368383         if( (row == 0) && (chg == 0x04) ) /* Ctrl-@ (NUL) */
r9785r9786
371386      }
372387      else
373388      {
374         keyrows[row] = newval;
389         kbd->keyrows[row] = newval;
375390      }
376      repeat = repeater;
391      kbd->repeat = kbd->repeater;
377392   }
378   else if ( key && (keyrows[lastrow] & mask) && repeat == 0 )
393   else if ( kbd->key && (keyrows[kbd->lastrow] & kbd->mask) && kbd->repeat == 0 )
379394   {
380      kay_kbd_in(device->machine, key);
395      kay_kbd_in(device->machine, kbd->key);
381396   }
382397}
383398
r9785r9786
391406static WRITE8_HANDLER ( kaypro2_const_w )
392407{
393408   if (data & 1)
394      kbd_head = kbd_tail = 0;
409      kbd->head = kbd->tail = 0;
395410}
396411
397412#endif
r9785r9786
403418 ******************************************************/
404419static void kay_kbd_in( running_machine *machine, UINT8 data )
405420{
421   kaypro_state *state = machine->driver_data<kaypro_state>();
422   kay_kbd_t *kbd = state->kbd;
406423   UINT8 kbd_head_old;
407424
408   kbd_head_old = kbd_head;
409   kbd_buff[kbd_head] = data;
410   kbd_head = (kbd_head + 1) % sizeof(kbd_buff);
425   kbd_head_old = kbd->head;
426   kbd->buff[kbd->head] = data;
427   kbd->head = (kbd->head + 1) % sizeof(kbd->buff);
411428   /* will the buffer overflow ? */
412   if (kbd_head == kbd_tail)
429   if (kbd->head == kbd->tail)
413430   {
414      kbd_head = kbd_head_old;
431      kbd->head = kbd_head_old;
415432      kay_kbd_d_w(machine, 4);
416433   }
417434   else
r9785r9786
419436}
420437
421438
422UINT8 kay_kbd_c_r( void )
439UINT8 kay_kbd_c_r( running_machine *machine )
423440{
424441/*  d4 transmit buffer empty - 1=ok to send
425442    d2 appears to be receive buffer empty - 1=ok to receive
426443    d0 keyboard buffer empty - 1=key waiting to be used */
427444
428   UINT8 data = control_status;
445   kaypro_state *state = machine->driver_data<kaypro_state>();
446   kay_kbd_t *kbd = state->kbd;
447   UINT8 data = kbd->control_status;
429448
430   if( kbd_head != kbd_tail )
449   if( kbd->head != kbd->tail )
431450      data++;
432451
433452   return data;
434453}
435454
436UINT8 kay_kbd_d_r( void )
455UINT8 kay_kbd_d_r( running_machine *machine )
437456{
438457/* return next key in buffer */
439458
459   kaypro_state *state = machine->driver_data<kaypro_state>();
460   kay_kbd_t *kbd = state->kbd;
440461   UINT8 data = 0;
441462
442   if (kbd_tail != kbd_head)
463   if (kbd->tail != kbd->head)
443464   {
444      data = kbd_buff[kbd_tail];
445      kbd_tail = (kbd_tail + 1) % sizeof(kbd_buff);
465      data = kbd->buff[kbd->tail];
466      kbd->tail = (kbd->tail + 1) % sizeof(kbd->buff);
446467   }
447468
448469   return data;
r9785r9786
450471
451472static TIMER_CALLBACK( kay_kbd_beepoff )
452473{
453   beep_set_state(kay_kbd_beeper, 0);
454   control_status |= 4;
474   kaypro_state *state = machine->driver_data<kaypro_state>();
475   kay_kbd_t *kbd = state->kbd;
476   beep_set_state(kbd->beeper, 0);
477   kbd->control_status |= 4;
455478}
456479
457480void kay_kbd_d_w( running_machine *machine, UINT8 data )
r9785r9786
463486    08 - mute
464487    16 - unmute */
465488
489   kaypro_state *state = machine->driver_data<kaypro_state>();
490   kay_kbd_t *kbd = state->kbd;
466491   UINT16 length = 0;
467492
468493   if (data & 0x10)
469      beep_on = 1;
494      kbd->beep_on = 1;
470495   else
471496   if (data & 0x08)
472      beep_on = 0;
497      kbd->beep_on = 0;
473498   else
474   if (beep_on)
499   if (kbd->beep_on)
475500   {
476501      if (data & 0x04)
477502         length = 400;
r9785r9786
484509
485510      if (length)
486511      {
487         control_status &= 0xfb;
512         kbd->control_status &= 0xfb;
488513         timer_set(machine, ATTOTIME_IN_MSEC(length), NULL, 0, kay_kbd_beepoff);
489         beep_set_state(kay_kbd_beeper, 1);
514         beep_set_state(kbd->beeper, 1);
490515      }
491516   }
492517}
src/mess/machine/microtan.c
r9785r9786
3333
3434#define LOG(x)  do { if (VERBOSE) logerror x; } while (0)
3535
36static UINT8 microtan_keypad_column;
37static UINT8 microtan_keyboard_ascii;
3836
39static emu_timer *microtan_timer = NULL;
4037
41static int via_0_irq_line = CLEAR_LINE;
42static int via_1_irq_line = CLEAR_LINE;
43static int kbd_irq_line = CLEAR_LINE;
4438
45static UINT8 keyrows[10] = { 0,0,0,0,0,0,0,0,0,0 };
4639static const char keyboard[8][9][8] = {
4740    { /* normal */
4841        { 27,'1','2','3','4','5','6','7'},
r9785r9786
153146
154147static void microtan_set_irq_line(running_machine *machine)
155148{
149   microtan_state *state = machine->driver_data<microtan_state>();
156150    /* The 6502 IRQ line is active low and probably driven
157151       by open collector outputs (guess). Since MAME/MESS use
158152       a non-0 value for ASSERT_LINE we OR the signals here */
159    cputag_set_input_line(machine, "maincpu", 0, via_0_irq_line | via_1_irq_line | kbd_irq_line);
153    cputag_set_input_line(machine, "maincpu", 0, state->via_0_irq_line | state->via_1_irq_line | state->kbd_irq_line);
160154}
161155
162156static running_device *cassette_device_image(running_machine *machine)
r9785r9786
233227
234228static void via_0_irq(running_device *device, int state)
235229{
230   microtan_state *drvstate = device->machine->driver_data<microtan_state>();
236231    LOG(("microtan_via_0_irq %d\n", state));
237    via_0_irq_line = state;
232    drvstate->via_0_irq_line = state;
238233    microtan_set_irq_line(device->machine);
239234}
240235
r9785r9786
305300
306301static void via_1_irq(running_device *device, int state)
307302{
303   microtan_state *drvstate = device->machine->driver_data<microtan_state>();
308304    LOG(("microtan_via_1_irq %d\n", state));
309    via_1_irq_line = state;
305    drvstate->via_1_irq_line = state;
310306    microtan_set_irq_line(device->machine);
311307}
312308
r9785r9786
364360
365361 READ8_HANDLER ( microtan_bffx_r )
366362{
363   microtan_state *state = space->machine->driver_data<microtan_state>();
367364    int data = 0xff;
368365    switch( offset & 3 )
369366    {
370367    case  0: /* BFF0: read enables chunky graphics */
371        microtan_chunky_graphics = 1;
368        state->chunky_graphics = 1;
372369        LOG(("microtan_bff0_r: -> %02x (chunky graphics on)\n", data));
373370        break;
374371    case  1: /* BFF1: read undefined (?) */
r9785r9786
378375        LOG(("microtan_bff2_r: -> %02x\n", data));
379376        break;
380377    default: /* BFF3: read keyboard ASCII value */
381        data = microtan_keyboard_ascii;
378        data = state->keyboard_ascii;
382379        LOG(("microtan_bff3_r: -> %02x (keyboard ASCII)\n", data));
383380    }
384381    return data;
r9785r9786
393390
394391WRITE8_HANDLER ( microtan_bffx_w )
395392{
393   microtan_state *state = space->machine->driver_data<microtan_state>();
396394    switch( offset & 3 )
397395    {
398396    case 0: /* BFF0: write reset keyboard interrupt flag */
399397        /* This removes bit 7 from the ASCII value of the last key pressed. */
400398        LOG(("microtan_bff0_w: %d <- %02x (keyboard IRQ clear )\n", offset, data));
401        microtan_keyboard_ascii &= ~0x80;
402        kbd_irq_line = CLEAR_LINE;
399        state->keyboard_ascii &= ~0x80;
400        state->kbd_irq_line = CLEAR_LINE;
403401        microtan_set_irq_line(space->machine);
404402        break;
405403    case 1: /* BFF1: write delayed NMI */
r9785r9786
408406        break;
409407    case 2: /* BFF2: write keypad column write (what is this meant for?) */
410408        LOG(("microtan_bff2_w: %d <- %02x (keypad column)\n", offset, data));
411        microtan_keypad_column = data;
409        state->keypad_column = data;
412410        break;
413411    default: /* BFF3: write disable chunky graphics */
414412        LOG(("microtan_bff3_w: %d <- %02x (chunky graphics off)\n", offset, data));
415        microtan_chunky_graphics = 0;
413        state->chunky_graphics = 0;
416414    }
417415}
418416
419417static void store_key(running_machine *machine, int key)
420418{
419   microtan_state *state = machine->driver_data<microtan_state>();
421420    LOG(("microtan: store key '%c'\n", key));
422    microtan_keyboard_ascii = key | 0x80;
423    kbd_irq_line = ASSERT_LINE;
421    state->keyboard_ascii = key | 0x80;
422    state->kbd_irq_line = ASSERT_LINE;
424423    microtan_set_irq_line(machine);
425424}
426425
427426INTERRUPT_GEN( microtan_interrupt )
428427{
428   microtan_state *state = device->machine->driver_data<microtan_state>();
429429    int mod, row, col, chg, newvar;
430    static int lastrow = 0, mask = 0x00, key = 0x00, repeat = 0, repeater = 0;
431430   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8" };
432431
433    if( repeat )
432    if( state->repeat )
434433    {
435        if( !--repeat )
436            repeater = 4;
434        if( !--state->repeat )
435            state->repeater = 4;
437436    }
438    else if( repeater )
437    else if( state->repeater )
439438    {
440        repeat = repeater;
439        state->repeat = state->repeater;
441440    }
442441
443442
444443    row = 9;
445444    newvar = input_port_read(device->machine, "ROW8");
446    chg = keyrows[--row] ^ newvar;
445    chg = state->keyrows[--row] ^ newvar;
447446
448447   while ( !chg && row > 0)
449448   {
450449      newvar = input_port_read(device->machine, keynames[row - 1]);
451      chg = keyrows[--row] ^ newvar;
450      chg = state->keyrows[--row] ^ newvar;
452451   }
453452    if (!chg)
454453      --row;
455454
456455    if (row >= 0)
457456    {
458        repeater = 0x00;
459        mask = 0x00;
460        key = 0x00;
461        lastrow = row;
457        state->repeater = 0x00;
458        state->mask = 0x00;
459        state->key = 0x00;
460        state->lastrow = row;
462461        /* CapsLock LED */
463462      if( row == 3 && chg == 0x80 )
464         set_led_status(device->machine, 1, (keyrows[3] & 0x80) ? 0 : 1);
463         set_led_status(device->machine, 1, (state->keyrows[3] & 0x80) ? 0 : 1);
465464
466465        if (newvar & chg)  /* key(s) pressed ? */
467466        {
468467            mod = 0;
469468
470469            /* Shift modifier */
471            if ( (keyrows[5] & 0x10) || (keyrows[6] & 0x80) )
470            if ( (state->keyrows[5] & 0x10) || (state->keyrows[6] & 0x80) )
472471                mod |= 1;
473472
474473            /* Control modifier */
475            if (keyrows[3] & 0x40)
474            if (state->keyrows[3] & 0x40)
476475                mod |= 2;
477476
478477            /* CapsLock modifier */
479            if (keyrows[3] & 0x80)
478            if (state->keyrows[3] & 0x80)
480479                mod |= 4;
481480
482481            /* find newvar key */
483            mask = 0x01;
482            state->mask = 0x01;
484483            for (col = 0; col < 8; col ++)
485484            {
486                if (chg & mask)
485                if (chg & state->mask)
487486                {
488                    newvar &= mask;
489                    key = keyboard[mod][row][col];
487                    newvar &= state->mask;
488                    state->key = keyboard[mod][row][col];
490489                    break;
491490                }
492                mask <<= 1;
491                state->mask <<= 1;
493492            }
494            if( key )   /* normal key */
493            if( state->key )   /* normal key */
495494            {
496                repeater = 30;
497                store_key(device->machine, key);
495                state->repeater = 30;
496                store_key(device->machine, state->key);
498497            }
499498            else
500499            if( (row == 0) && (chg == 0x04) ) /* Ctrl-@ (NUL) */
501500                store_key(device->machine, 0);
502            keyrows[row] |= newvar;
501            state->keyrows[row] |= newvar;
503502        }
504503        else
505504        {
506            keyrows[row] = newvar;
505            state->keyrows[row] = newvar;
507506        }
508        repeat = repeater;
507        state->repeat = state->repeater;
509508    }
510509    else
511    if ( key && (keyrows[lastrow] & mask) && repeat == 0 )
510    if ( state->key && (state->keyrows[state->lastrow] & state->mask) && state->repeat == 0 )
512511    {
513        store_key(device->machine, key);
512        store_key(device->machine, state->key);
514513    }
515514}
516515
517516DRIVER_INIT( microtan )
518517{
518   microtan_state *state = machine->driver_data<microtan_state>();
519519    UINT8 *dst = memory_region(machine, "gfx2");
520520    int i;
521521    address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
r9785r9786
570570            break;
571571    }
572572
573   microtan_timer = timer_alloc(machine, microtan_read_cassette, NULL);
573   state->timer = timer_alloc(machine, microtan_read_cassette, NULL);
574574}
575575
576576MACHINE_RESET( microtan )
577577{
578    int i;
578   microtan_state *state = machine->driver_data<microtan_state>();
579   int i;
579580   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8" };
580581
581582   for (i = 1; i < 10;  i++)
582583   {
583        keyrows[i] = input_port_read(machine, keynames[i-1]);
584      state->keyrows[i] = input_port_read(machine, keynames[i-1]);
584585   }
585    set_led_status(machine, 1, (keyrows[3] & 0x80) ? 0 : 1);
586   set_led_status(machine, 1, (state->keyrows[3] & 0x80) ? 0 : 1);
586587}
src/mess/machine/x68k_hdc.c
r9785r9786
1919#include "devices/harddriv.h"
2020#include "image.h"
2121
22static struct hd_state hd;
23
2422static TIMER_CALLBACK( req_delay )
2523{
2624   sasi_ctrl_t* sasi = (sasi_ctrl_t*)ptr;
r9785r9786
5250   sasi->status = 0x00;
5351   sasi->status_port = 0x00;
5452   sasi->phase = SASI_PHASE_BUSFREE;
55   hd.current_block = 0;
5653}
5754
5855DEVICE_IMAGE_CREATE( sasihd )
src/mess/machine/x68k_hdc.h
r9785r9786
9696   int req;  // REQ
9797};
9898
99struct hd_state
100{
101   int current_block;
102   int current_pos;
103};
104
10599DEVICE_START( x68k_hdc );
106100
107101DEVICE_IMAGE_CREATE( sasihd );
src/mess/machine/msx.c
r9785r9786
329329   msx_vdp_interrupt
330330};
331331
332
333332MACHINE_START( msx )
334333{
335334   TMS9928A_configure(&tms9928a_interface);
r9785r9786
339338MACHINE_START( msx2 )
340339{
341340   msx_state *state = machine->driver_data<msx_state>();
341   state->port_c_old = 0xff;
342342   state->dsk_stat = 0x7f;
343343}
344344
r9785r9786
783783
784784static WRITE8_DEVICE_HANDLER ( msx_ppi_port_c_w )
785785{
786   static int old_val = 0xff;
787
786   msx_state *state = device->machine->driver_data<msx_state>();
788787   /* caps lock */
789   if ( (old_val ^ data) & 0x40)
788   if ( (state->port_c_old ^ data) & 0x40)
790789      set_led_status (device->machine,1, !(data & 0x40) );
791790
792791   /* key click */
793   if ( (old_val ^ data) & 0x80)
792   if ( (state->port_c_old ^ data) & 0x80)
794793      dac_signed_data_w (device->machine->device("dac"), (data & 0x80 ? 0x7f : 0));
795794
796795   /* cassette motor on/off */
797   if ( (old_val ^ data) & 0x10)
796   if ( (state->port_c_old ^ data) & 0x10)
798797      cassette_change_state(cassette_device_image(device->machine),
799798                  (data & 0x10) ? CASSETTE_MOTOR_DISABLED :
800799                              CASSETTE_MOTOR_ENABLED,
801800                  CASSETTE_MASK_MOTOR);
802801
803802   /* cassette signal write */
804   if ( (old_val ^ data) & 0x20)
803   if ( (state->port_c_old ^ data) & 0x20)
805804      cassette_output(cassette_device_image(device->machine), (data & 0x20) ? -1.0 : 1.0);
806805
807   old_val = data;
806   state->port_c_old = data;
808807}
809808
810809static READ8_DEVICE_HANDLER( msx_ppi_port_b_r )
src/mess/machine/kaypro.c
r9785r9786
22#include "emu.h"
33#include "cpu/z80/z80.h"
44#include "machine/ctronics.h"
5#include "machine/kay_kbd.h"
65#include "devices/snapquik.h"
76#include "includes/kaypro.h"
87#include "devices/flopdrv.h"
r9785r9786
283282   else
284283   if (offset == 1)
285284//      return z80sio_d_r(device, 1);
286      return kay_kbd_d_r();
285      return kay_kbd_d_r(device->machine);
287286   else
288287   if (offset == 2)
289288      return z80sio_c_r(device, 0);
290289   else
291290//      return z80sio_c_r(device, 1);
292      return kay_kbd_c_r();
291      return kay_kbd_c_r(device->machine);
293292}
294293
295294WRITE8_DEVICE_HANDLER( kaypro_sio_w )
src/mess/machine/intv.c
r9785r9786
66#define INTELLIVOICE_MASK   0x02
77#define ECS_MASK         0x01
88
9UINT8 intv_gramdirty;
10UINT8 intv_gram[512];
11UINT8 intv_gramdirtybytes[512];
129
13UINT16 *intvkbd_dualport_ram;
1410
1511WRITE16_HANDLER ( intvkbd_dualport16_w )
1612{
13   intv_state *state = space->machine->driver_data<intv_state>();
1714   unsigned char *RAM;
1815
19   COMBINE_DATA(&intvkbd_dualport_ram[offset]);
16   COMBINE_DATA(&state->intvkbd_dualport_ram[offset]);
2017
2118   /* copy the LSB over to the 6502 OP RAM, in case they are opcodes */
2219   RAM    = memory_region(space->machine, "keyboard");
r9785r9786
2522
2623READ8_HANDLER ( intvkbd_dualport8_lsb_r )
2724{
28   return (UINT8) (intvkbd_dualport_ram[offset] >> 0);
25   intv_state *state = space->machine->driver_data<intv_state>();
26   return (UINT8) (state->intvkbd_dualport_ram[offset] >> 0);
2927}
3028
3129WRITE8_HANDLER ( intvkbd_dualport8_lsb_w )
3230{
31   intv_state *state = space->machine->driver_data<intv_state>();
3332   unsigned char *RAM;
3433
35   intvkbd_dualport_ram[offset] &= ~0x00FF;
36   intvkbd_dualport_ram[offset] |= ((UINT16) data) << 0;
34   state->intvkbd_dualport_ram[offset] &= ~0x00FF;
35   state->intvkbd_dualport_ram[offset] |= ((UINT16) data) << 0;
3736
3837   /* copy over to the 6502 OP RAM, in case they are opcodes */
3938   RAM    = memory_region(space->machine, "keyboard");
4039   RAM[offset] = data;
4140}
4241
43static int intvkbd_keyboard_col;
44static int tape_int_pending;
45static int sr1_int_pending;
4642
47int intvkbd_text_blanked;
4843
4944READ8_HANDLER ( intvkbd_dualport8_msb_r )
5045{
46   intv_state *state = space->machine->driver_data<intv_state>();
5147   unsigned char rv;
5248
5349   if (offset < 0x100)
r9785r9786
7975            logerror("TAPE: Read %02x from 0x40%02x - Clocked Comp (339/13)\n",rv,offset);
8076            break;
8177         case 0x006:
82            if (sr1_int_pending)
78            if (state->sr1_int_pending)
8379               rv = 0x00;
8480            else
8581               rv = 0x80;
8682            logerror("TAPE: Read %02x from 0x40%02x - SR1 Int Pending\n",rv,offset);
8783            break;
8884         case 0x007:
89            if (tape_int_pending)
85            if (state->tape_int_pending)
9086               rv = 0x00;
9187            else
9288               rv = 0x80;
r9785r9786
9490            break;
9591         case 0x060:   /* Keyboard Read */
9692            rv = 0xff;
97            if (intvkbd_keyboard_col == 0)
93            if (state->intvkbd_keyboard_col == 0)
9894               rv = input_port_read(space->machine, "ROW0");
99            if (intvkbd_keyboard_col == 1)
95            if (state->intvkbd_keyboard_col == 1)
10096               rv = input_port_read(space->machine, "ROW1");
101            if (intvkbd_keyboard_col == 2)
97            if (state->intvkbd_keyboard_col == 2)
10298               rv = input_port_read(space->machine, "ROW2");
103            if (intvkbd_keyboard_col == 3)
99            if (state->intvkbd_keyboard_col == 3)
104100               rv = input_port_read(space->machine, "ROW3");
105            if (intvkbd_keyboard_col == 4)
101            if (state->intvkbd_keyboard_col == 4)
106102               rv = input_port_read(space->machine, "ROW4");
107            if (intvkbd_keyboard_col == 5)
103            if (state->intvkbd_keyboard_col == 5)
108104               rv = input_port_read(space->machine, "ROW5");
109            if (intvkbd_keyboard_col == 6)
105            if (state->intvkbd_keyboard_col == 6)
110106               rv = input_port_read(space->machine, "ROW6");
111            if (intvkbd_keyboard_col == 7)
107            if (state->intvkbd_keyboard_col == 7)
112108               rv = input_port_read(space->machine, "ROW7");
113            if (intvkbd_keyboard_col == 8)
109            if (state->intvkbd_keyboard_col == 8)
114110               rv = input_port_read(space->machine, "ROW8");
115            if (intvkbd_keyboard_col == 9)
111            if (state->intvkbd_keyboard_col == 9)
116112               rv = input_port_read(space->machine, "ROW9");
117113            break;
118114         case 0x80:
119115            rv = 0x00;
120116            logerror("TAPE: Read %02x from 0x40%02x, clear tape int pending\n",rv,offset);
121            tape_int_pending = 0;
117            state->tape_int_pending = 0;
122118            break;
123119         case 0xa0:
124120            rv = 0x00;
125121            logerror("TAPE: Read %02x from 0x40%02x, clear SR1 int pending\n",rv,offset);
126            sr1_int_pending = 0;
122            state->sr1_int_pending = 0;
127123            break;
128124         case 0xc0:
129125         case 0xc1:
r9785r9786
145141            rv = intvkbd_tms9927_r(space, offset-0xc0);
146142            break;
147143         default:
148            rv = (intvkbd_dualport_ram[offset]&0x0300)>>8;
144            rv = (state->intvkbd_dualport_ram[offset]&0x0300)>>8;
149145            logerror("Unknown read %02x from 0x40%02x\n",rv,offset);
150146            break;
151147      }
152148      return rv;
153149   }
154150   else
155      return (intvkbd_dualport_ram[offset]&0x0300)>>8;
151      return (state->intvkbd_dualport_ram[offset]&0x0300)>>8;
156152}
157153
158static int tape_interrupts_enabled;
159static int tape_unknown_write[6];
160static int tape_motor_mode;
161154static const char *const tape_motor_mode_desc[8] =
162155{
163156   "IDLE", "IDLE", "IDLE", "IDLE",
r9785r9786
166159
167160WRITE8_HANDLER ( intvkbd_dualport8_msb_w )
168161{
162   intv_state *state = space->machine->driver_data<intv_state>();
169163   unsigned int mask;
170164
171165   if (offset < 0x100)
r9785r9786
173167      switch (offset)
174168      {
175169         case 0x020:
176            tape_motor_mode &= 3;
170            state->tape_motor_mode &= 3;
177171            if (data & 1)
178               tape_motor_mode |= 4;
179            logerror("TAPE: Motor Mode: %s\n",tape_motor_mode_desc[tape_motor_mode]);
172               state->tape_motor_mode |= 4;
173            logerror("TAPE: Motor Mode: %s\n",tape_motor_mode_desc[state->tape_motor_mode]);
180174            break;
181175         case 0x021:
182            tape_motor_mode &= 5;
176            state->tape_motor_mode &= 5;
183177            if (data & 1)
184               tape_motor_mode |= 2;
185            logerror("TAPE: Motor Mode: %s\n",tape_motor_mode_desc[tape_motor_mode]);
178               state->tape_motor_mode |= 2;
179            logerror("TAPE: Motor Mode: %s\n",tape_motor_mode_desc[state->tape_motor_mode]);
186180            break;
187181         case 0x022:
188            tape_motor_mode &= 6;
182            state->tape_motor_mode &= 6;
189183            if (data & 1)
190               tape_motor_mode |= 1;
191            logerror("TAPE: Motor Mode: %s\n",tape_motor_mode_desc[tape_motor_mode]);
184               state->tape_motor_mode |= 1;
185            logerror("TAPE: Motor Mode: %s\n",tape_motor_mode_desc[state->tape_motor_mode]);
192186            break;
193187         case 0x023:
194188         case 0x024:
195189         case 0x025:
196190         case 0x026:
197191         case 0x027:
198            tape_unknown_write[offset - 0x23] = (data & 1);
192            state->tape_unknown_write[offset - 0x23] = (data & 1);
199193            break;
200194         case 0x040:
201            tape_unknown_write[5] = (data & 1);
195            state->tape_unknown_write[5] = (data & 1);
202196            break;
203197         case 0x041:
204198            if (data & 1)
205199               logerror("TAPE: Tape Interrupts Enabled\n");
206200            else
207201               logerror("TAPE: Tape Interrupts Disabled\n");
208            tape_interrupts_enabled = (data & 1);
202            state->tape_interrupts_enabled = (data & 1);
209203            break;
210204         case 0x042:
211205            if (data & 1)
r9785r9786
215209            break;
216210         case 0x043:
217211            if (data & 0x01)
218               intvkbd_text_blanked = 0;
212               state->intvkbd_text_blanked = 0;
219213            else
220               intvkbd_text_blanked = 1;
214               state->intvkbd_text_blanked = 1;
221215            break;
222216         case 0x044:
223            intvkbd_keyboard_col &= 0x0e;
224            intvkbd_keyboard_col |= (data&0x01);
217            state->intvkbd_keyboard_col &= 0x0e;
218            state->intvkbd_keyboard_col |= (data&0x01);
225219            break;
226220         case 0x045:
227            intvkbd_keyboard_col &= 0x0d;
228            intvkbd_keyboard_col |= ((data&0x01)<<1);
221            state->intvkbd_keyboard_col &= 0x0d;
222            state->intvkbd_keyboard_col |= ((data&0x01)<<1);
229223            break;
230224         case 0x046:
231            intvkbd_keyboard_col &= 0x0b;
232            intvkbd_keyboard_col |= ((data&0x01)<<2);
225            state->intvkbd_keyboard_col &= 0x0b;
226            state->intvkbd_keyboard_col |= ((data&0x01)<<2);
233227            break;
234228         case 0x047:
235            intvkbd_keyboard_col &= 0x07;
236            intvkbd_keyboard_col |= ((data&0x01)<<3);
229            state->intvkbd_keyboard_col &= 0x07;
230            state->intvkbd_keyboard_col |= ((data&0x01)<<3);
237231            break;
238232         case 0x80:
239233            logerror("TAPE: Write to 0x40%02x, clear tape int pending\n",offset);
240            tape_int_pending = 0;
234            state->tape_int_pending = 0;
241235            break;
242236         case 0xa0:
243237            logerror("TAPE: Write to 0x40%02x, clear SR1 int pending\n",offset);
244            sr1_int_pending = 0;
238            state->sr1_int_pending = 0;
245239            break;
246240         case 0xc0:
247241         case 0xc1:
r9785r9786
269263   }
270264   else
271265   {
272      mask = intvkbd_dualport_ram[offset] & 0x00ff;
273      intvkbd_dualport_ram[offset] = mask | ((data<<8)&0x0300);
266      mask = state->intvkbd_dualport_ram[offset] & 0x00ff;
267      state->intvkbd_dualport_ram[offset] = mask | ((data<<8)&0x0300);
274268   }
275269}
276270
277271READ16_HANDLER( intv_gram_r )
278272{
279   //logerror("read: %d = GRAM(%d)\n",intv_gram[offset],offset);
280   return (int)intv_gram[offset];
273   intv_state *state = space->machine->driver_data<intv_state>();
274   //logerror("read: %d = GRAM(%d)\n",state->gram[offset],offset);
275   return (int)state->gram[offset];
281276}
282277
283278WRITE16_HANDLER( intv_gram_w )
284279{
280   intv_state *state = space->machine->driver_data<intv_state>();
285281    data &= 0xFF;
286282
287   intv_gram[offset] = data;
288   intv_gramdirtybytes[offset] = 1;
289    intv_gramdirty = 1;
283   state->gram[offset] = data;
284   state->gramdirtybytes[offset] = 1;
285    state->gramdirty = 1;
290286}
291287
292static unsigned char intv_ram8[256];
293288
294289READ16_HANDLER( intv_ram8_r )
295290{
296   //logerror("%x = ram8_r(%x)\n",intv_ram8[offset],offset);
297   return (int)intv_ram8[offset];
291   intv_state *state = space->machine->driver_data<intv_state>();
292   //logerror("%x = ram8_r(%x)\n",state->ram8[offset],offset);
293   return (int)state->ram8[offset];
298294}
299295
300296WRITE16_HANDLER( intv_ram8_w )
301297{
298   intv_state *state = space->machine->driver_data<intv_state>();
302299   //logerror("ram8_w(%x) = %x\n",offset,data);
303   intv_ram8[offset] = data&0xff;
300   state->ram8[offset] = data&0xff;
304301}
305302
306UINT16 intv_ram16[0x160];
307303
308304READ16_HANDLER( intv_ram16_r )
309305{
310   //logerror("%x = ram16_r(%x)\n",intv_ram16[offset],offset);
311   return (int)intv_ram16[offset];
306   intv_state *state = space->machine->driver_data<intv_state>();
307   //logerror("%x = ram16_r(%x)\n",state->ram16[offset],offset);
308   return (int)state->ram16[offset];
312309}
313310
314311WRITE16_HANDLER( intv_ram16_w )
315312{
313   intv_state *state = space->machine->driver_data<intv_state>();
316314   //logerror("%g: WRITING TO GRAM offset = %d\n",timer_get_time(machine),offset);
317315   //logerror("ram16_w(%x) = %x\n",offset,data);
318   intv_ram16[offset] = data&0xffff;
316   state->ram16[offset] = data&0xffff;
319317}
320318
321319static int intv_load_rom_file(device_image_interface &image)
r9785r9786
497495
498496INTERRUPT_GEN( intv_interrupt )
499497{
498   intv_state *state = device->machine->driver_data<intv_state>();
500499   cputag_set_input_line(device->machine, "maincpu", CP1610_INT_INTRM, ASSERT_LINE);
501   sr1_int_pending = 1;
500   state->sr1_int_pending = 1;
502501   timer_set(device->machine, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(3791), NULL, 0, intv_interrupt_complete);
503502   intv_stic_screenrefresh(device->machine);
504503}
src/mess/video/stic.c
r9785r9786
33
44
55/* STIC variables */
6struct intv_sprite_type intv_sprite[8];
7UINT8 intv_sprite_buffers[8][16][128];
8int intv_collision_registers[8];
9int intv_stic_handshake;
10int intv_border_color;
11int intv_color_stack[4];
12int intv_color_stack_mode = 0; // for now
13int intv_color_stack_offset = 0; // for now
14int intv_col_delay = 0;  // for now
15int intv_row_delay = 0;  // for now
16int intv_left_edge_inhibit = 0;  // for now
17int intv_top_edge_inhibit = 0;  // for now
186
197READ16_HANDLER( intv_stic_r )
208{
9   intv_state *state = space->machine->driver_data<intv_state>();
2110   //logerror("%x = stic_r(%x)\n",0,offset);
2211   switch (offset)
2312   {
r9785r9786
2918      case 0x1d:
3019      case 0x1e:
3120      case 0x1f:
32            return intv_collision_registers[offset & 0x07];
21            return state->collision_registers[offset & 0x07];
3322      case 0x21:
34         intv_color_stack_mode = 1;
23         state->color_stack_mode = 1;
3524         //logerror("Setting color stack mode\n");
3625         break;
3726   }
r9785r9786
4029
4130WRITE16_HANDLER( intv_stic_w )
4231{
43   struct intv_sprite_type *s;
32   intv_state *state = space->machine->driver_data<intv_state>();
33   intv_sprite_type *s;
4434
4535   //logerror("stic_w(%x) = %x\n",offset,data);
4636   switch (offset)
r9785r9786
5444      case 0x05:
5545      case 0x06:
5646      case 0x07:
57         s =  &intv_sprite[offset & 0x07];
47         s =  &state->sprite[offset & 0x07];
5848         s->doublex = !!(data & 0x0400);
5949         s->visible = !!(data & 0x0200);
6050         s->coll = !!(data & 0x0100);
r9785r9786
6959      case 0x0d:
7060      case 0x0e:
7161      case 0x0f:
72         s =  &intv_sprite[offset & 0x07];
62         s =  &state->sprite[offset & 0x07];
7363         s->yflip = !!(data & 0x0800);
7464         s->xflip = !!(data & 0x0400);
7565         s->quady = !!(data & 0x0200);
r9785r9786
8676      case 0x15:
8777      case 0x16:
8878      case 0x17:
89         s =  &intv_sprite[offset & 0x07];
79         s =  &state->sprite[offset & 0x07];
9080            s->behind_foreground = !!(data & 0x2000);
9181            s->grom = !(data & 0x0800);
9282         s->card = ((data >> 3) & 0xFF);
r9785r9786
10494            //a MOB's own collision bit is *always* zero, even if a
10595            //one is poked into it
10696            data &= (~(1 << (offset & 0x07))) & 0x03FF;
107            intv_collision_registers[offset & 0x07] = data;
97            state->collision_registers[offset & 0x07] = data;
10898         break;
10999      /* Display enable */
110100      case 0x20:
111101         //logerror("***Writing a %x to the STIC handshake\n",data);
112         intv_stic_handshake = 1;
102         state->stic_handshake = 1;
113103         break;
114104      /* Graphics Mode */
115105      case 0x21:
116         intv_color_stack_mode = 0;
106         state->color_stack_mode = 0;
117107         break;
118108      /* Color Stack */
119109      case 0x28:
r9785r9786
121111      case 0x2a:
122112      case 0x2b:
123113         logerror("Setting color_stack[%x] = %x (%x)\n",offset&0x3,data&0xf,cpu_get_pc(space->cpu));
124         intv_color_stack[offset&0x3] = data&0xf;
114         state->color_stack[offset&0x3] = data&0xf;
125115         break;
126116      /* Border Color */
127117      case 0x2c:
128118         //logerror("***Writing a %x to the border color\n",data);
129         intv_border_color = data & 0xf;
119         state->border_color = data & 0xf;
130120         break;
131121      /* Framing */
132122      case 0x30:
133         intv_col_delay = data & 0x7;
123         state->col_delay = data & 0x7;
134124         break;
135125      case 0x31:
136         intv_row_delay = data & 0x7;
126         state->row_delay = data & 0x7;
137127         break;
138128      case 0x32:
139         intv_left_edge_inhibit = (data & 0x01);
140         intv_top_edge_inhibit = (data & 0x02)>>1;
129         state->left_edge_inhibit = (data & 0x01);
130         state->top_edge_inhibit = (data & 0x02)>>1;
141131         break;
142132   }
143133}
src/mess/video/coco6847.c
r9785r9786
147147   /* saved palette; used with CoCo 3 */
148148   UINT32 saved_palette[16];
149149
150   UINT32 saved_artifacting, saved_c0, saved_c1;
151   UINT32 expanded_colors[128];
152
150153   /* 2^7 modes, 256/16 character groups, background/foreground */
151154   UINT8 colordata[128][256/16][2];
152155
r9785r9786
13561359
13571360   UINT32 artifacting, c0, c1;
13581361   UINT32 colors[16];
1359   static UINT32 saved_artifacting, saved_c0, saved_c1;
1360   static UINT32 expanded_colors[128];
13611362   const double *factors;
13621363   UINT8 val;
13631364   UINT32 new_line[256];
r9785r9786
13811382   c0 = line[i];
13821383
13831384   /* do we need to update our artifact colors table? */
1384   if ((artifacting != saved_artifacting) || (c0 != saved_c0) || (c1 != saved_c1))
1385   if ((artifacting != m6847->saved_artifacting) || (c0 != m6847->saved_c0) || (c1 != m6847->saved_c1))
13851386   {
1386      saved_artifacting = artifacting;
1387      saved_c0 = colors[0] = c0;
1388      saved_c1 = colors[15] = c1;
1387      m6847->saved_artifacting = artifacting;
1388      m6847->saved_c0 = colors[0] = c0;
1389      m6847->saved_c1 = colors[15] = c1;
13891390
13901391      /* mix the other colors */
13911392      for (i = 1; i <= 14; i++)
r9785r9786
13971398               |   (mix_color(factors[2], c0 >>  0, c1 >>  0) <<  0);
13981399      }
13991400      for (i = 0; i < 128; i++)
1400         expanded_colors[i] = colors[artifactcorrection[i]];
1401         m6847->expanded_colors[i] = colors[artifactcorrection[i]];
14011402   }
14021403
14031404   /* artifact the line */
r9785r9786
14101411         |   ((line[i + 2] == c1) ? 0x02 : 0x00)
14111412         |   ((line[i + 3] == c1) ? 0x01 : 0x00);
14121413
1413      new_line[i + 0] = expanded_colors[val * 2 + 0];
1414      new_line[i + 1] = expanded_colors[val * 2 + 1];
1414      new_line[i + 0] = m6847->expanded_colors[val * 2 + 0];
1415      new_line[i + 1] = m6847->expanded_colors[val * 2 + 1];
14151416   }
14161417
14171418   /* and copy the results back */
src/mess/video/m6847.c
r9785r9786
183183   UINT8 attrs[384];
184184   m6847_pixel screendata[192][32];
185185
186   UINT32 saved_artifacting, saved_c0, saved_c1;
187   UINT32 expanded_colors[128];
188
186189   /* saved palette; used with CoCo 3 */
187190   UINT32 saved_palette[16];
188191
r9785r9786
195198
196199
197200
198static void apply_artifacts(running_machine *machine, UINT32 *line);
201static void apply_artifacts(running_device *device, UINT32 *line);
199202
200203
201204static const UINT8 pal_round_fontdata8x12[] =
r9785r9786
17871790      if ((attrs & (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0))
17881791         == (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0))
17891792      {
1790         apply_artifacts(device->machine, line + 32);
1793         apply_artifacts(device, line + 32);
17911794      }
17921795   }
17931796   else
r9785r9786
20602063
20612064
20622065
2063static void apply_artifacts(running_machine *machine, UINT32 *line)
2066static void apply_artifacts(running_device *device, UINT32 *line)
20642067{
20652068   /* Boy this code sucks; this code was adapted from the old M6847
20662069     * artifacting implmentation.  The only reason that it didn't look as
r9785r9786
21102113      15, 11,      15, 11,      15, 15,      15, 15
21112114   };
21122115
2116   mc6847_state *mc6847 = get_safe_token(device);
21132117   UINT32 artifacting, c0, c1;
21142118   UINT32 colors[16];
2115   static UINT32 saved_artifacting, saved_c0, saved_c1;
2116   static UINT32 expanded_colors[128];
21172119   const double *factors;
21182120   UINT8 val;
21192121   UINT32 new_line[256];
21202122   int i;
21212123
21222124   /* are we artifacting? */
2123   artifacting = input_port_read_safe(machine, "artifacting", 0x00) & 0x03;
2125   artifacting = input_port_read_safe(device->machine, "artifacting", 0x00) & 0x03;
21242126   if (artifacting == 0x00)
21252127      return;
21262128   artifacting &= 0x01;
r9785r9786
21372139   c0 = line[i];
21382140
21392141   /* do we need to update our artifact colors table? */
2140   if ((artifacting != saved_artifacting) || (c0 != saved_c0) || (c1 != saved_c1))
2142   if ((artifacting != mc6847->saved_artifacting) || (c0 != mc6847->saved_c0) || (c1 != mc6847->saved_c1))
21412143   {
2142      saved_artifacting = artifacting;
2143      saved_c0 = colors[0] = c0;
2144      saved_c1 = colors[15] = c1;
2144      mc6847->saved_artifacting = artifacting;
2145      mc6847->saved_c0 = colors[0] = c0;
2146      mc6847->saved_c1 = colors[15] = c1;
21452147
21462148      /* mix the other colors */
21472149      for (i = 1; i <= 14; i++)
r9785r9786
21532155               |   (mix_color(factors[2], c0 >>  0, c1 >>  0) <<  0);
21542156      }
21552157      for (i = 0; i < 128; i++)
2156         expanded_colors[i] = colors[artifactcorrection[i]];
2158         mc6847->expanded_colors[i] = colors[artifactcorrection[i]];
21572159   }
21582160
21592161   /* artifact the line */
r9785r9786
21662168         |   ((line[i + 2] == c1) ? 0x02 : 0x00)
21672169         |   ((line[i + 3] == c1) ? 0x01 : 0x00);
21682170
2169      new_line[i + 0] = expanded_colors[val * 2 + 0];
2170      new_line[i + 1] = expanded_colors[val * 2 + 1];
2171      new_line[i + 0] = mc6847->expanded_colors[val * 2 + 0];
2172      new_line[i + 1] = mc6847->expanded_colors[val * 2 + 1];
21712173   }
21722174
21732175   /* and copy the results back */
src/mess/video/microtan.c
r9785r9786
1919UINT8 microtan_chunky_graphics = 0;
2020UINT8 *microtan_chunky_buffer = NULL;
2121
22static tilemap_t *bg_tilemap;
2322
2423WRITE8_HANDLER( microtan_videoram_w )
2524{
2625   microtan_state *state = space->machine->driver_data<microtan_state>();
2726   UINT8 *videoram = state->videoram;
28   if ((videoram[offset] != data) || (microtan_chunky_buffer[offset] != microtan_chunky_graphics))
27   if ((videoram[offset] != data) || (state->chunky_buffer[offset] != state->chunky_graphics))
2928   {
3029      videoram[offset] = data;
31      tilemap_mark_tile_dirty(bg_tilemap, offset);
32      microtan_chunky_buffer[offset] = microtan_chunky_graphics;
30      tilemap_mark_tile_dirty(state->bg_tilemap, offset);
31      state->chunky_buffer[offset] = state->chunky_graphics;
3332   }
3433}
3534
r9785r9786
3736{
3837   microtan_state *state = machine->driver_data<microtan_state>();
3938   UINT8 *videoram = state->videoram;
40   int gfxn = microtan_chunky_buffer[tile_index];
39   int gfxn = state->chunky_buffer[tile_index];
4140   int code = videoram[tile_index];
4241
4342   SET_TILE_INFO(gfxn, code, 0, 0);
r9785r9786
4544
4645VIDEO_START( microtan )
4746{
48   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
47   microtan_state *state = machine->driver_data<microtan_state>();
48   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
4949      8, 16, 32, 16);
5050
51   microtan_chunky_buffer = auto_alloc_array(machine, UINT8, 0x200);
52   memset(microtan_chunky_buffer, 0, 0x200);
53   microtan_chunky_graphics = 0;
51   state->chunky_buffer = auto_alloc_array(machine, UINT8, 0x200);
52   memset(state->chunky_buffer, 0, 0x200);
53   state->chunky_graphics = 0;
5454}
5555
5656VIDEO_UPDATE( microtan )
5757{
58   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
58   microtan_state *state = screen->machine->driver_data<microtan_state>();
59   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
5960   return 0;
6061}
src/mess/video/ef9345.c
r9785r9786
853853         }
854854         if (cmd&1)
855855         {
856            if ((registers[7] & 0x80) == 0x00) {registers[7] |= 0x80; return;}
856            if ((registers[7] & 0x80) == 0x00) { registers[7] |= 0x80; return; }
857857            registers[7] &= 0x80;
858858            inc_x(7);
859859         }
src/mess/video/intv.c
r9785r9786
44#define FOREGROUND_BIT 0x0010
55
66/* initialized to non-zero, because we divide by it */
7static UINT8 tms9927_num_rows;
87
98INLINE void intv_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color)
109{
r9785r9786
1312
1413VIDEO_START( intv )
1514{
15   intv_state *state = machine->driver_data<intv_state>();
1616   //int i,j,k;
1717
18   tms9927_num_rows = 25;
18   state->tms9927_num_rows = 25;
1919   VIDEO_START_CALL(generic_bitmapped);
2020
2121#if 0
2222    for (i = 0; i < 8; i++) {
23        struct intv_sprite_type* s = &intv_sprite[i];
23        intv_sprite_type* s = &state->sprite[i];
2424        s->visible = 0;
2525        s->xpos = 0;
2626        s->ypos = 0;
r9785r9786
3939        s->dirty = 1;
4040        for (j = 0; j < 16; j++) {
4141            for (k = 0; k < 128; k++) {
42                intv_sprite_buffers[i][j][k] = 0;
42                state->sprite_buffers[i][j][k] = 0;
4343            }
4444        }
45        intv_collision_registers[i] = 0;
45        state->collision_registers[i] = 0;
4646    }
4747    for(i = 0; i < 4; i++) {
48        intv_color_stack[i] = 0;
48        state->color_stack[i] = 0;
4949    }
50    intv_color_stack_mode = 0;
51    intv_color_stack_offset = 0;
52    intv_stic_handshake = 0;
53    intv_border_color = 0;
54    intv_col_delay = 0;
55    intv_row_delay = 0;
56    intv_left_edge_inhibit = 0;
57    intv_top_edge_inhibit = 0;
50    state->color_stack_mode = 0;
51    state->color_stack_offset = 0;
52    state->stic_handshake = 0;
53    state->border_color = 0;
54    state->col_delay = 0;
55    state->row_delay = 0;
56    state->left_edge_inhibit = 0;
57    state->top_edge_inhibit = 0;
5858
59    intv_gramdirty = 1;
59    state->gramdirty = 1;
6060    for(i=0;i<64;i++) {
61        intv_gram[i] = 0;
62        intv_gramdirtybytes[i] = 1;
61        state->gram[i] = 0;
62        state->gramdirtybytes[i] = 1;
6363    }
6464#endif
6565}
6666
6767
68static int sprites_collide(int spriteNum0, int spriteNum1) {
68static int sprites_collide(intv_state *state, int spriteNum0, int spriteNum1) {
6969    INT16 x1, x2, y1, y2, w1, w2, h1, h2, x0, y0, r0y, r1y,
7070          width, height, x, y;
7171
72    struct intv_sprite_type* s1 = &intv_sprite[spriteNum0];
73    struct intv_sprite_type* s2 = &intv_sprite[spriteNum1];
72    intv_sprite_type* s1 = &state->sprite[spriteNum0];
73    intv_sprite_type* s2 = &state->sprite[spriteNum1];
7474
7575    x1 = s1->xpos-8; x2 = s2->xpos-8;
7676    y1 = (s1->ypos-8)<<1; y2 = (s2->ypos-8)<<1;
r9785r9786
9292    height = MIN(y1+h1, y2+h2) - y0;
9393    for (x = 0; x < width; x++) {
9494        for (y = 0; y < height; y++) {
95            if (intv_sprite_buffers[spriteNum0][x0-x1+x][r0y+y] &&
96                    intv_sprite_buffers[spriteNum1][x0-x2+x][r1y+y])
95            if (state->sprite_buffers[spriteNum0][x0-x1+x][r0y+y] &&
96                    state->sprite_buffers[spriteNum1][x0-x2+x][r1y+y])
9797                return TRUE;
9898        }
9999    }
r9785r9786
101101    return FALSE;
102102}
103103
104static void determine_sprite_collisions(void)
104static void determine_sprite_collisions(intv_state *state)
105105{
106106    //check sprite to sprite collisions
107107    int i, j;
108108    for (i = 0; i < 7; i++) {
109        struct intv_sprite_type* s1 = &intv_sprite[i];
109        intv_sprite_type* s1 = &state->sprite[i];
110110        if (s1->xpos == 0 || !s1->coll)
111111            continue;
112112
113113        for (j = i+1; j < 8; j++) {
114            struct intv_sprite_type* s2 = &intv_sprite[j];
114            intv_sprite_type* s2 = &state->sprite[j];
115115            if (s2->xpos == 0 || !s2->coll)
116116                continue;
117117
118            if (sprites_collide(i, j)) {
118            if (sprites_collide(state, i, j)) {
119119                s1->collision |= (1 << j);
120120                s2->collision |= (1 << i);
121121            }
r9785r9786
125125
126126static void render_sprites(running_machine *machine)
127127{
128   intv_state *state = machine->driver_data<intv_state>();
128129    INT32 cardMemoryLocation, pixelSize;
129130    INT32 spritePixelHeight;
130131    INT32 nextMemoryLocation;
r9785r9786
137138    UINT8* memory = memory_region(machine, "maincpu");
138139
139140    for (i = 0; i < 8; i++) {
140      struct intv_sprite_type* s = &intv_sprite[i];
141      intv_sprite_type* s = &state->sprite[i];
141142
142143        if (s->grom)
143144            cardMemoryLocation = (s->card << 3);
r9785r9786
152153            if (s->grom)
153154                nextData = memory[(0x3000+nextMemoryLocation)<<1];
154155            else if (nextMemoryLocation < 0x200)
155                nextData = intv_gram[nextMemoryLocation];
156                nextData = state->gram[nextMemoryLocation];
156157            else
157158                nextData = 0xFFFF;
158159            nextX = (s->xflip ? (s->doublex ? 15 : 7) : 0);
159160            nextY = (s->yflip ? (spritePixelHeight - j - 1) : j);
160161            xInc = (s->xflip ? -1: 1);
161            intv_sprite_buffers[i][nextX][nextY] = ((nextData & 0x0080) != 0);
162            intv_sprite_buffers[i][nextX + xInc][nextY] = (s->doublex
162            state->sprite_buffers[i][nextX][nextY] = ((nextData & 0x0080) != 0);
163            state->sprite_buffers[i][nextX + xInc][nextY] = (s->doublex
163164                    ? ((nextData & 0x0080) != 0)
164165                    : ((nextData & 0x0040) != 0));
165            intv_sprite_buffers[i][nextX + (2*xInc)][nextY] = (s->doublex
166            state->sprite_buffers[i][nextX + (2*xInc)][nextY] = (s->doublex
166167                    ? ((nextData & 0x0040) != 0)
167168                    : ((nextData & 0x0020) != 0));
168            intv_sprite_buffers[i][nextX + (3*xInc)][nextY] = (s->doublex
169            state->sprite_buffers[i][nextX + (3*xInc)][nextY] = (s->doublex
169170                    ? ((nextData & 0x0040) != 0)
170171                    : ((nextData & 0x0010) != 0));
171            intv_sprite_buffers[i][nextX + (4*xInc)][nextY] = (s->doublex
172            state->sprite_buffers[i][nextX + (4*xInc)][nextY] = (s->doublex
172173                    ? ((nextData & 0x0020) != 0)
173174                    : ((nextData & 0x0008) != 0));
174            intv_sprite_buffers[i][nextX + (5*xInc)][nextY] = (s->doublex
175            state->sprite_buffers[i][nextX + (5*xInc)][nextY] = (s->doublex
175176                    ? ((nextData & 0x0020) != 0)
176177                    : ((nextData & 0x0004) != 0));
177            intv_sprite_buffers[i][nextX + (6*xInc)][nextY] = (s->doublex
178            state->sprite_buffers[i][nextX + (6*xInc)][nextY] = (s->doublex
178179                    ? ((nextData & 0x0010) != 0)
179180                    : ((nextData & 0x0002) != 0));
180            intv_sprite_buffers[i][nextX + (7*xInc)][nextY] = (s->doublex
181            state->sprite_buffers[i][nextX + (7*xInc)][nextY] = (s->doublex
181182                    ? ((nextData & 0x0010) != 0)
182183                    : ((nextData & 0x0001) != 0));
183184            if (!s->doublex)
184185                continue;
185186
186            intv_sprite_buffers[i][nextX + (8*xInc)][nextY] =
187            state->sprite_buffers[i][nextX + (8*xInc)][nextY] =
187188                    ((nextData & 0x0008) != 0);
188            intv_sprite_buffers[i][nextX + (9*xInc)][nextY] =
189            state->sprite_buffers[i][nextX + (9*xInc)][nextY] =
189190                    ((nextData & 0x0008) != 0);
190            intv_sprite_buffers[i][nextX + (10*xInc)][nextY] =
191            state->sprite_buffers[i][nextX + (10*xInc)][nextY] =
191192                    ((nextData & 0x0004) != 0);
192            intv_sprite_buffers[i][nextX + (11*xInc)][nextY] =
193            state->sprite_buffers[i][nextX + (11*xInc)][nextY] =
193194                    ((nextData & 0x0004) != 0);
194            intv_sprite_buffers[i][nextX + (12*xInc)][nextY] =
195            state->sprite_buffers[i][nextX + (12*xInc)][nextY] =
195196                    ((nextData & 0x0002) != 0);
196            intv_sprite_buffers[i][nextX + (13*xInc)][nextY] =
197            state->sprite_buffers[i][nextX + (13*xInc)][nextY] =
197198                    ((nextData & 0x0002) != 0);
198            intv_sprite_buffers[i][nextX + (14*xInc)][nextY] =
199            state->sprite_buffers[i][nextX + (14*xInc)][nextY] =
199200                    ((nextData & 0x0001) != 0);
200            intv_sprite_buffers[i][nextX + (15*xInc)][nextY] =
201            state->sprite_buffers[i][nextX + (15*xInc)][nextY] =
201202                    ((nextData & 0x0001) != 0);
202203        }
203204
r9785r9786
267268
268269static void render_color_stack_mode(running_machine *machine, bitmap_t *bitmap)
269270{
271   intv_state *state = machine->driver_data<intv_state>();
270272    UINT8 h, csPtr = 0, nexty = 0;
271273    UINT16 nextCard, nextx = 0;
272274    UINT8 *ram = memory_region(machine, "maincpu");
273275
274276    for (h = 0; h < 240; h++) {
275        nextCard = intv_ram16[h];
277        nextCard = state->ram16[h];
276278
277279        //colored squares mode
278280        if ((nextCard & 0x1800) == 0x1000) {
279            UINT8 csColor = intv_color_stack[csPtr];
281            UINT8 csColor = state->color_stack[csPtr];
280282            UINT8 color0 = nextCard & 0x0007;
281283            UINT8 color1 = (nextCard & 0x0038) >> 3;
282284            UINT8 color2 = (nextCard & 0x01C0) >> 6;
r9785r9786
300302
301303            fgcolor = ((nextCard & 0x1000) >> 9) |
302304                    (nextCard & 0x0007) | FOREGROUND_BIT;
303            bgcolor = intv_color_stack[csPtr] & 0x0F;
305            bgcolor = state->color_stack[csPtr] & 0x0F;
304306
305307            isGrom = !(nextCard & 0x0800);
306308            if (isGrom) {
r9785r9786
312314            }
313315            else {
314316                memoryLocation = (nextCard & 0x01F8);
315                memory = intv_gram;
317                memory = state->gram;
316318                for (j = 0; j < 16; j+=2)
317319                    render_line(machine, bitmap, memory[memoryLocation+(j>>1)],
318320                            nextx, nexty+j, fgcolor, bgcolor);
r9785r9786
328330
329331static void render_fg_bg_mode(running_machine *machine, bitmap_t *bitmap)
330332{
333   intv_state *state = machine->driver_data<intv_state>();
331334    UINT8 i, j, isGrom, fgcolor, bgcolor, nexty = 0;
332335    UINT16 nextCard, memoryLocation, nextx = 0;
333336    UINT8* memory;
334337    UINT8* ram = memory_region(machine, "maincpu");
335338
336339    for (i = 0; i < 240; i++) {
337        nextCard = intv_ram16[i];
340        nextCard = state->ram16[i];
338341        fgcolor = (nextCard & 0x0007) | FOREGROUND_BIT;
339342        bgcolor = ((nextCard & 0x2000) >> 11) |
340343                ((nextCard & 0x1600) >> 9);
r9785r9786
349352        }
350353        else {
351354            memoryLocation = (nextCard & 0x01F8);
352            memory = intv_gram;
355            memory = state->gram;
353356            for (j = 0; j < 16; j+=2)
354357                render_line(machine, bitmap, memory[memoryLocation+(j>>1)],
355358                        nextx, nexty+j, fgcolor, bgcolor);
r9785r9786
365368
366369static void copy_sprites_to_background(running_machine *machine, bitmap_t *bitmap)
367370{
371   intv_state *state = machine->driver_data<intv_state>();
368372    UINT8 width, currentPixel;
369373    UINT8 borderCollision, foregroundCollision;
370374    UINT8 spritePixelHeight, x, y;
r9785r9786
372376    INT32 nextX;
373377
374378    for (i = 7; i >= 0; i--) {
375      struct intv_sprite_type *s = &intv_sprite[i];
379      intv_sprite_type *s = &state->sprite[i];
376380        if (s->xpos == 0 ||
377381                (!s->coll && !s->visible))
378382            continue;
r9785r9786
390394        for (y = 0; y < spritePixelHeight; y++) {
391395            for (x = 0; x < width; x++) {
392396                //if this sprite pixel is not on, then don't paint it
393                if (!intv_sprite_buffers[i][x][y])
397                if (!state->sprite_buffers[i][x][y])
394398                    continue;
395399
396400                nextX = leftX + (x<<1);
397401                //if the next pixel location is on the border, then we
398402                //have a border collision and we can ignore painting it
399                if (nextX < (intv_row_delay ? 8 : 0) || nextX > 317 ||
400                        nextY < (intv_col_delay ? 16 : 0) || nextY > 191)
403                if (nextX < (state->row_delay ? 8 : 0) || nextX > 317 ||
404                        nextY < (state->col_delay ? 16 : 0) || nextY > 191)
401405                {
402406                    borderCollision = TRUE;
403407                    continue;
r9785r9786
432436
433437static void render_background(running_machine *machine, bitmap_t *bitmap)
434438{
435   if (intv_color_stack_mode)
439   intv_state *state = machine->driver_data<intv_state>();
440   if (state->color_stack_mode)
436441        render_color_stack_mode(machine, bitmap);
437442    else
438443        render_fg_bg_mode(machine, bitmap);
r9785r9786
441446#ifdef UNUSED_CODE
442447static void draw_background(running_machine *machine, bitmap_t *bitmap, int transparency)
443448{
449   intv_state *state = machine->driver_data<intv_state>();
444450   // First, draw the background
445451   int offs = 0;
446452   int value = 0;
r9785r9786
456462
457463   int j;
458464
459   if (intv_color_stack_mode == 1)
465   if (state->color_stack_mode == 1)
460466   {
461      intv_color_stack_offset = 0;
467      state->color_stack_offset = 0;
462468      for(row = 0; row < 12; row++)
463469      {
464470         for(col = 0; col < 20; col++)
465471         {
466            value = intv_ram16[offs];
472            value = state->ram16[offs];
467473
468474            n_bit = value & 0x2000;
469475            p_bit = value & 0x1000;
r9785r9786
476482               colorc = (value>>6)&0x7;
477483               colord = ((n_bit>>11)&0x4) + ((value>>9)&0x3);
478484               // color 7 if the top of the color stack in this mode
479               if (colora == 7) colora = intv_color_stack[3];
480               if (colorb == 7) colorb = intv_color_stack[3];
481               if (colorc == 7) colorc = intv_color_stack[3];
482               if (colord == 7) colord = intv_color_stack[3];
485               if (colora == 7) colora = state->color_stack[3];
486               if (colorb == 7) colorb = state->color_stack[3];
487               if (colorc == 7) colorc = state->color_stack[3];
488               if (colord == 7) colord = state->color_stack[3];
483489               plot_box(bitmap,col*16,row*16,8,8,(colora<<1)+1);
484490               plot_box(bitmap,col*16+8,row*16,8,8,(colorb<<1)+1);
485491               plot_box(bitmap,col*16,row*16+8,8,8,(colorc<<1)+1);
r9785r9786
489495            {
490496               if (n_bit) // next color
491497               {
492                  intv_color_stack_offset += 1;
493                  intv_color_stack_offset &= 3;
498                  state->color_stack_offset += 1;
499                  state->color_stack_offset &= 3;
494500               }
495501
496502               if (p_bit) // pastel color set
r9785r9786
498504               else
499505                  fgcolor = value&0x7;
500506
501               bgcolor = intv_color_stack[intv_color_stack_offset];
507               bgcolor = state->color_stack[state->color_stack_offset];
502508               code = (value>>3)&0xff;
503509
504510               if (g_bit) // read from gram
505511               {
506512                  code %= 64;  // keep from going outside the array
507                  //if (intv_gramdirtybytes[code] == 1)
513                  //if (state->gramdirtybytes[code] == 1)
508514                  {
509515                     decodechar(machine->gfx[1],
510516                           code,
511                           intv_gram,
517                           state->gram,
512518                           machine->config->gfxdecodeinfo[1].gfxlayout);
513                     intv_gramdirtybytes[code] = 0;
519                     state->gramdirtybytes[code] = 0;
514520                  }
515521                  // Draw GRAM char
516522                  drawgfx(bitmap,machine->gfx[1],
r9785r9786
552558      {
553559         for(col = 0; col < 20; col++)
554560         {
555            value = intv_ram16[offs];
561            value = state->ram16[offs];
556562            fgcolor = value & 0x07;
557563            bgcolor = ((value & 0x2000)>>11)+((value & 0x1600)>>9);
558564            code = (value & 0x01f8)>>3;
559565
560566            if (value & 0x0800) // read for GRAM
561567            {
562               //if (intv_gramdirtybytes[code] == 1)
568               //if (state->gramdirtybytes[code] == 1)
563569               {
564570                  decodechar(machine->gfx[1],
565571                        code,
566                        intv_gram,
572                        state->gram,
567573                        machine->config->gfxdecodeinfo[1].gfxlayout);
568                  intv_gramdirtybytes[code] = 0;
574                  state->gramdirtybytes[code] = 0;
569575               }
570576               // Draw GRAM char
571577               drawgfx(bitmap,machine->gfx[1],
r9785r9786
593599#ifdef UNUSED_FUNCTION
594600static void draw_sprites(running_machine *machine, bitmap_t *bitmap, int behind_foreground)
595601{
602   intv_state *state = machine->driver_data<intv_state>();
596603    int i;
597604    int code;
598605
599606    for(i=7;i>=0;--i)
600607    {
601        struct intv_sprite_type *s = &intv_sprite[i];
608        intv_sprite_type *s = &state->sprite[i];
602609        if (s->visible && (s->behind_foreground == behind_foreground))
603610        {
604611            code = s->card;
r9785r9786
607614                code %= 64;  // keep from going outside the array
608615                if (s->yres == 1)
609616                {
610                    //if (intv_gramdirtybytes[code] == 1)
617                    //if (state->gramdirtybytes[code] == 1)
611618                    {
612619                        decodechar(machine->gfx[1],
613620                           code,
614                           intv_gram,
621                           state->gram,
615622                           machine->config->gfxdecodeinfo[1].gfxlayout);
616                        intv_gramdirtybytes[code] = 0;
623                        state->gramdirtybytes[code] = 0;
617624                    }
618625                    // Draw GRAM char
619626                    drawgfxzoom_transpen(bitmap,&machine->screen[0].visarea,machine->gfx[1],
r9785r9786
625632                }
626633                else
627634                {
628                    //if ((intv_gramdirtybytes[code] == 1) || (intv_gramdirtybytes[code+1] == 1))
635                    //if ((state->gramdirtybytes[code] == 1) || (state->gramdirtybytes[code+1] == 1))
629636                    {
630637                        decodechar(machine->gfx[1],
631638                           code,
632                           intv_gram,
639                           state->gram,
633640                           machine->config->gfxdecodeinfo[1].gfxlayout);
634641                        decodechar(machine->gfx[1],
635642                           code+1,
636                           intv_gram,
643                           state->gram,
637644                           machine->config->gfxdecodeinfo[1].gfxlayout);
638                        intv_gramdirtybytes[code] = 0;
639                        intv_gramdirtybytes[code+1] = 0;
645                        state->gramdirtybytes[code] = 0;
646                        state->gramdirtybytes[code+1] = 0;
640647                    }
641648                    // Draw GRAM char
642649                    drawgfxzoom_transpen(bitmap,&machine->screen[0].visarea,machine->gfx[1],
r9785r9786
688695
689696static void draw_borders(running_machine *machine, bitmap_t *bm)
690697{
691   if (intv_left_edge_inhibit)
692      plot_box(bm, 0, 0, 16-intv_col_delay*2, 16*12, (intv_border_color<<1)+1);
698   intv_state *state = machine->driver_data<intv_state>();
699   if (state->left_edge_inhibit)
700      plot_box(bm, 0, 0, 16-state->col_delay*2, 16*12, (state->border_color<<1)+1);
693701
694   if (intv_top_edge_inhibit)
695      plot_box(bm, 0, 0, 16*20, 16-intv_row_delay*2, (intv_border_color<<1)+1);
702   if (state->top_edge_inhibit)
703      plot_box(bm, 0, 0, 16*20, 16-state->row_delay*2, (state->border_color<<1)+1);
696704}
697705
698static int col_delay = 0;
699static int row_delay = 0;
700
701706void intv_stic_screenrefresh(running_machine *machine)
702707{
708   intv_state *state = machine->driver_data<intv_state>();
703709   int i;
704710
705   if (intv_stic_handshake != 0)
711   if (state->stic_handshake != 0)
706712   {
707      intv_stic_handshake = 0;
713      state->stic_handshake = 0;
708714      // Render the background
709715      render_background(machine, machine->generic.tmpbitmap);
710716      // Render the sprites into their buffers
711717      render_sprites(machine);
712      for (i = 0; i < 8; i++) intv_sprite[i].collision = 0;
718      for (i = 0; i < 8; i++) state->sprite[i].collision = 0;
713719      // Copy the sprites to the background
714720      copy_sprites_to_background(machine, machine->generic.tmpbitmap);
715      determine_sprite_collisions();
716      for (i = 0; i < 8; i++) intv_collision_registers[i] |= intv_sprite[i].collision;
721      determine_sprite_collisions(state);
722      for (i = 0; i < 8; i++) state->collision_registers[i] |= state->sprite[i].collision;
717723      /* draw the screen borders if enabled */
718724      draw_borders(machine, machine->generic.tmpbitmap);
719725   }
720726   else
721727   {
722728      /* STIC disabled, just fill with border color */
723      bitmap_fill(machine->generic.tmpbitmap, NULL, (intv_border_color<<1)+1);
729      bitmap_fill(machine->generic.tmpbitmap, NULL, (state->border_color<<1)+1);
724730   }
725   col_delay = intv_col_delay;
726   row_delay = intv_row_delay;
727731}
728732
729733
730734/* very rudimentary support for the tms9927 character generator IC */
731735
732static UINT8 tms9927_cursor_col;
733static UINT8 tms9927_cursor_row;
734static UINT8 tms9927_last_row;
735736
736737 READ8_HANDLER( intvkbd_tms9927_r )
737738{
739   intv_state *state = space->machine->driver_data<intv_state>();
738740   UINT8 rv;
739741   switch (offset)
740742   {
741743      case 8:
742         rv = tms9927_cursor_row;
744         rv = state->tms9927_cursor_row;
743745         break;
744746      case 9:
745747         /* note: this is 1-based */
746         rv = tms9927_cursor_col;
748         rv = state->tms9927_cursor_col;
747749         break;
748750      case 11:
749         tms9927_last_row = (tms9927_last_row + 1) % tms9927_num_rows;
750         rv = tms9927_last_row;
751         state->tms9927_last_row = (state->tms9927_last_row + 1) % state->tms9927_num_rows;
752         rv = state->tms9927_last_row;
751753         break;
752754      default:
753755         rv = 0;
r9785r9786
757759
758760WRITE8_HANDLER( intvkbd_tms9927_w )
759761{
762   intv_state *state = space->machine->driver_data<intv_state>();
760763   switch (offset)
761764   {
762765      case 3:
763         tms9927_num_rows = (data & 0x3f) + 1;
766         state->tms9927_num_rows = (data & 0x3f) + 1;
764767         break;
765768      case 6:
766         tms9927_last_row = data;
769         state->tms9927_last_row = data;
767770         break;
768771      case 11:
769         tms9927_last_row = (tms9927_last_row + 1) % tms9927_num_rows;
772         state->tms9927_last_row = (state->tms9927_last_row + 1) % state->tms9927_num_rows;
770773         break;
771774      case 12:
772775         /* note: this is 1-based */
773         tms9927_cursor_col = data;
776         state->tms9927_cursor_col = data;
774777         break;
775778      case 13:
776         tms9927_cursor_row = data;
779         state->tms9927_cursor_row = data;
777780         break;
778781   }
779782}
r9785r9786
790793   VIDEO_UPDATE_CALL(generic_bitmapped);
791794
792795   /* if the intvkbd text is not blanked, overlay it */
793   if (!intvkbd_text_blanked)
796   if (!state->intvkbd_text_blanked)
794797   {
795      current_row = (tms9927_last_row + 1) % tms9927_num_rows;
798      current_row = (state->tms9927_last_row + 1) % state->tms9927_num_rows;
796799      for(y=0;y<24;y++)
797800      {
798801         for(x=0;x<40;x++)
r9785r9786
805808               0,0,
806809               x<<3,y<<3, 0);
807810         }
808         if (current_row == tms9927_cursor_row)
811         if (current_row == state->tms9927_cursor_row)
809812         {
810813            /* draw the cursor as a solid white block */
811814            /* (should use a filled rect here!) */
r9785r9786
814817               191, /* a block */
815818               7,   /* white   */
816819               0,0,
817               (tms9927_cursor_col-1)<<3,y<<3, 0);
820               (state->tms9927_cursor_col-1)<<3,y<<3, 0);
818821         }
819         current_row = (current_row + 1) % tms9927_num_rows;
822         current_row = (current_row + 1) % state->tms9927_num_rows;
820823      }
821824   }
822825
823826#if 0
824827   // debugging
825   c = tape_motor_mode_desc[tape_motor_mode][0];
828   c = tape_motor_mode_desc[state->tape_motor_mode][0];
826829   drawgfx_transpen(bitmap,&machine->screen[0].visarea, machine->gfx[1],
827830      c,
828831      1,
r9785r9786
831834   for(y=0;y<5;y++)
832835   {
833836      drawgfx_transpen(bitmap,&machine->screen[0].visarea, machine->gfx[1],
834         tape_unknown_write[y]+'0',
837         state->tape_unknown_write[y]+'0',
835838         1,
836839         0,0,
837840         0*8,(y+2)*8, 0);
838841   }
839842   drawgfx_transpen(bitmap,&machine->screen[0].visarea, machine->gfx[1],
840         tape_unknown_write[5]+'0',
843         state->tape_unknown_write[5]+'0',
841844         1,
842845         0,0,
843846         0*8,8*8, 0);
844847   drawgfx_transpen(bitmap,&machine->screen[0].visarea, machine->gfx[1],
845         tape_interrupts_enabled+'0',
848         state->tape_interrupts_enabled+'0',
846849         1,
847850         0,0,
848851         0*8,10*8, 0);
src/mess/includes/gb.h
r9785r9786
134134
135135   /* SGB variables */
136136   UINT8      sgb_atf_data[4050];      /* (SGB) Attributes files */
137   INT8 sgb_packets;
138   UINT8 sgb_bitcount;
139   UINT8 sgb_bytecount;
140   UINT8 sgb_start;
141   UINT8 sgb_rest;
142   UINT8 sgb_controller_no;
143   UINT8 sgb_controller_mode;
144   UINT8 sgb_data[112];
145   UINT32 sgb_atf;
137146
138147   /* Cartridge/mapper */
139148   UINT16      MBCType;            /* MBC type: 0 for none */
src/mess/includes/msx.h
r9785r9786
4646   UINT8 superloadrunner_bank;
4747   UINT8 korean90in1_bank;
4848   UINT8 *top_page;
49   int port_c_old;
4950};
5051
5152
src/mess/includes/kaypro.h
r9785r9786
3131   UINT8 framecnt;
3232   UINT16 cursor;
3333   UINT16 mc6845_video_address;
34   struct _kay_kbd_t *kbd;
3435};
3536
3637
38/*----------- defined in machine/kay_kbd.c -----------*/
39
40UINT8 kay_kbd_c_r( running_machine *machine );
41UINT8 kay_kbd_d_r( running_machine *machine );
42void kay_kbd_d_w( running_machine *machine, UINT8 data );
43INTERRUPT_GEN( kay_kbd_interrupt );
44MACHINE_RESET( kay_kbd );
45INPUT_PORTS_EXTERN( kay_kbd );
46
47
3748/*----------- defined in machine/kaypro.c -----------*/
3849
3950extern const z80pio_interface kayproii_pio_g_intf;
src/mess/includes/abc80x.h
r9785r9786
112112   // serial state
113113   int m_sio_rxcb;
114114   int m_sio_txcb;
115   int keylatch;
115116};
116117
117118class abc800m_state : public abc800_state
src/mess/includes/microtan.h
r9785r9786
2626      : driver_device(machine, config) { }
2727
2828   UINT8 *videoram;
29   UINT8 chunky_graphics;
30   UINT8 *chunky_buffer;
31   UINT8 keypad_column;
32   UINT8 keyboard_ascii;
33   emu_timer *timer;
34   int via_0_irq_line;
35   int via_1_irq_line;
36   int kbd_irq_line;
37   UINT8 keyrows[10];
38   int lastrow;
39   int mask;
40   int key;
41   int repeat;
42   int repeater;
43   tilemap_t *bg_tilemap;
2944};
3045
3146
r9785r9786
5166
5267/*----------- defined in video/microtan.c -----------*/
5368
54extern UINT8 microtan_chunky_graphics;
55extern UINT8 *microtan_chunky_buffer;
56
5769extern WRITE8_HANDLER ( microtan_videoram_w );
5870
5971extern VIDEO_START( microtan );
src/mess/includes/intv.h
r9785r9786
77#ifndef INTV_H_
88#define INTV_H_
99
10struct intv_sprite_type
10typedef struct
1111{
1212   int visible;
1313   int xpos;
r9785r9786
2424   int card;
2525   int color;
2626   int doubleyres;
27
2827   int dirty;
29};
28} intv_sprite_type;
3029
3130class intv_state : public driver_device
3231{
r9785r9786
3534      : driver_device(machine, config) { }
3635
3736   UINT8 *videoram;
37   intv_sprite_type sprite[8];
38   UINT8 sprite_buffers[8][16][128];
39   int color_stack_mode;
40   int collision_registers[8];
41   int color_stack_offset;
42   int color_stack[4];
43   int stic_handshake;
44   int border_color;
45   int col_delay;
46   int row_delay;
47   int left_edge_inhibit;
48   int top_edge_inhibit;
49   UINT8 gramdirty;
50   UINT8 gram[512];
51   UINT8 gramdirtybytes[512];
52   UINT16 ram16[0x160];
53   int intvkbd_text_blanked;
54   UINT16 *intvkbd_dualport_ram;
55   int intvkbd_keyboard_col;
56   int tape_int_pending;
57   int sr1_int_pending;
58   int tape_interrupts_enabled;
59   int tape_unknown_write[6];
60   int tape_motor_mode;
61   unsigned char ram8[256];
62   UINT8 tms9927_num_rows;
63   UINT8 tms9927_cursor_col;
64   UINT8 tms9927_cursor_row;
65   UINT8 tms9927_last_row;
3866};
3967
4068
r9785r9786
4371READ16_HANDLER( intv_stic_r );
4472WRITE16_HANDLER( intv_stic_w );
4573
46extern struct intv_sprite_type intv_sprite[];
47extern UINT8 intv_sprite_buffers[8][16][128];
48extern int intv_color_stack_mode;
49extern int intv_collision_registers[];
50extern int intv_color_stack_offset;
51extern int intv_color_stack[];
52extern int intv_stic_handshake;
53extern int intv_border_color;
54extern int intv_col_delay;
55extern int intv_row_delay;
56extern int intv_left_edge_inhibit;
57extern int intv_top_edge_inhibit;
5874
5975/*----------- defined in video/intv.c -----------*/
6076
r9785r9786
7086/*----------- defined in machine/intv.c -----------*/
7187
7288/*  for the console alone... */
73extern UINT8 intv_gramdirty;
74extern UINT8 intv_gram[];
75extern UINT8 intv_gramdirtybytes[];
76extern UINT16 intv_ram16[];
7789
7890DEVICE_START( intv_cart );
7991DEVICE_IMAGE_LOAD( intv_cart );
r9785r9786
92104READ8_HANDLER( intv_left_control_r );
93105
94106/* for the console + keyboard component... */
95extern int intvkbd_text_blanked;
96107
97108DEVICE_IMAGE_LOAD( intvkbd_cart );
98109
99extern UINT16 *intvkbd_dualport_ram;
100110WRITE16_HANDLER ( intvkbd_dualport16_w );
101111READ8_HANDLER ( intvkbd_dualport8_lsb_r );
102112WRITE8_HANDLER ( intvkbd_dualport8_lsb_w );
src/mess/formats/m65_snqk.c
r9785r9786
217217
218218static void microtan_snapshot_copy(running_machine *machine, UINT8 *snapshot_buff, int snapshot_size)
219219{
220   microtan_state *state = machine->driver_data<microtan_state>();
220221    UINT8 *RAM = memory_region(machine, "maincpu");
221222    address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
222223    via6522_device *via_0 = machine->device<via6522_device>("via6522_0");
r9785r9786
241242        /* 64 bytes of chunky graphics info */
242243        for (i = 0; i < 32*16; i++)
243244        {
244            microtan_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
245            state->chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
245246        }
246247        base += 64;
247248        microtan_set_cpu_regs(machine, snapshot_buff, base);
r9785r9786
292293        }
293294
294295        microtan_sound_w(space, 0, snapshot_buff[base++]);
295        microtan_chunky_graphics = snapshot_buff[base++];
296        state->chunky_graphics = snapshot_buff[base++];
296297
297298        /* first set of AY8910 registers */
298299        for (i = 0; i < 16; i++ )
r9785r9786
310311
311312        for (i = 0; i < 32*16; i++)
312313        {
313            microtan_chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
314            state->chunky_buffer[i] = (snapshot_buff[base+i/8] >> (i&7)) & 1;
314315        }
315316        base += 64;
316317
src/mess/drivers/zexall.c
r9785r9786
6060   UINT8 *rom = memory_region(machine, "romcode");
6161   UINT8 *ram = state->main_ram;
6262   int i;
63    /* fill main ram with zexall code */
64    for (i = 0; i < 0x228a; i++)
65   { ram[i] = rom[i];}
63   /* fill main ram with zexall code */
64   for (i = 0; i < 0x228a; i++)
65      ram[i] = rom[i];
6666   //fprintf(stderr,"MACHINE_RESET: copied romcode to maincpu\n");
6767}
6868
src/mess/drivers/oric.c
r9785r9786
3030#include "machine/6522via.h"
3131#include "machine/6551.h"
3232#include "machine/wd17xx.h"
33#include "includes/apple2.h"
3433
3534/*
3635    Explaination of memory regions:
r9785r9786
381380   DEVCB_NULL,
382381   DEVCB_NULL,
383382   FLOPPY_STANDARD_5_25_DSHD,
384    FLOPPY_OPTIONS_NAME(apple2),
383   FLOPPY_OPTIONS_NAME(apple2),
385384   NULL
386385};
387386
src/mess/drivers/abc80x.c
r9785r9786
341341   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
342342INPUT_PORTS_END
343343
344static int keylatch;
345344
346345static const UINT8 abc800_keycodes[7*4][8] =
347346{
r9785r9786
384383
385384static void scan_keyboard(running_machine *machine)
386385{
386   abc800_state *state = machine->driver_data<abc800_state>();
387387   UINT8 keycode = 0;
388388   UINT8 data;
389389   int table = 0, row, col;
r9785r9786
419419
420420   if (keycode)
421421   {
422      if (keycode != keylatch)
422      if (keycode != state->keylatch)
423423      {
424424         z80dart_device *m_dart = machine->device<z80dart_device>(Z80DART_TAG);
425425
426426         z80dart_dcdb_w(m_dart, 0);
427427         m_dart->receive_data(1, keycode);
428428
429         keylatch = keycode;
429         state->keylatch = keycode;
430430      }
431431   }
432432   else
433433   {
434      if (keylatch)
434      if (state->keylatch)
435435      {
436436         z80dart_device *m_dart = machine->device<z80dart_device>(Z80DART_TAG);
437437
438438         z80dart_dcdb_w(m_dart, 1);
439439         m_dart->receive_data(1, 0);
440440
441         keylatch = 0;
441         state->keylatch = 0;
442442      }
443443   }
444444}
r9785r9786
12371237
12381238static WRITE_LINE_DEVICE_HANDLER( ctc_z0_w )
12391239{
1240   abc800_state *drvstate = device->machine->driver_data<abc800_state>();
12401241   running_device *sio = device->machine->device(Z80SIO_TAG);
12411242
1242   static int m_sio_rxcb, m_sio_txcb; // FIXME
12431243
12441244   UINT8 sb = input_port_read(device->machine, "SB");
12451245
r9785r9786
12511251   }
12521252
12531253   // connected to SIO/2 RxCB through a thingy
1254   //m_sio_rxcb = ?
1255   z80dart_rxcb_w(sio, m_sio_rxcb);
1254   //drvstate->m_sio_rxcb = ?
1255   z80dart_rxcb_w(sio, drvstate->m_sio_rxcb);
12561256
12571257   // connected to SIO/2 TxCB through a JK divide by 2
1258   m_sio_txcb = !m_sio_txcb;
1259   z80dart_txcb_w(sio, m_sio_txcb);
1258   drvstate->m_sio_txcb = !drvstate->m_sio_txcb;
1259   z80dart_txcb_w(sio, drvstate->m_sio_txcb);
12601260}
12611261
12621262static WRITE_LINE_DEVICE_HANDLER( ctc_z1_w )
src/mess/drivers/mes.c
r9785r9786
5151    Also the screen dimensions are a guess. */
5252static VIDEO_UPDATE( mes )
5353{
54   mes_state *state = screen->machine->driver_data<mes_state>();   //static UINT8 framecnt=0;
54   mes_state *state = screen->machine->driver_data<mes_state>();
55   //static UINT8 framecnt=0;
5556   UINT8 y,ra,chr,gfx;
5657   UINT16 sy=0,ma=0,x,xx;
5758
src/mess/drivers/kaypro.c
r9785r9786
3636#include "cpu/z80/z80.h"
3737#include "cpu/z80/z80daisy.h"
3838#include "machine/ctronics.h"
39#include "machine/kay_kbd.h"
4039#include "sound/beep.h"
4140#include "devices/snapquik.h"
4241#include "devices/flopdrv.h"
src/mess/drivers/intv.c
r9785r9786
347347   AM_RANGE(0x3800, 0x39ff) AM_READWRITE( intv_gram_r, intv_gram_w )   /* GRAM,     8-bits wide */
348348   AM_RANGE(0x4800, 0x6fff) AM_ROM      /* Cartridges? */
349349   AM_RANGE(0x7000, 0x7fff) AM_ROM   AM_REGION("maincpu", 0x7000<<1)   /* Keyboard ROM */
350   AM_RANGE(0x8000, 0xbfff) AM_RAM_WRITE( intvkbd_dualport16_w ) AM_BASE(&intvkbd_dualport_ram)   /* Dual-port RAM */
350   AM_RANGE(0x8000, 0xbfff) AM_RAM_WRITE( intvkbd_dualport16_w ) AM_BASE_MEMBER(intv_state, intvkbd_dualport_ram)   /* Dual-port RAM */
351351ADDRESS_MAP_END
352352
353353static ADDRESS_MAP_START( intv2_mem , ADDRESS_SPACE_PROGRAM, 8)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team