Previous 199869 Revisions Next

r20998 Tuesday 12th February, 2013 at 20:24:17 UTC by Wilbert Pol
(MESS) intv.c: Reduce tagmap lookups (nw)
[src/mess/includes]intv.h
[src/mess/machine]intv.c
[src/mess/video]intv.c

trunk/src/mess/machine/intv.c
r20997r20998
4848      switch (offset)
4949      {
5050         case 0x000:
51            rv = ioport("TEST")->read() & 0x80;
51            rv = m_io_test->read() & 0x80;
5252            logerror("TAPE: Read %02x from 0x40%02x - XOR Data?\n",rv,offset);
5353            break;
5454         case 0x001:
55            rv = (ioport("TEST")->read() & 0x40) << 1;
55            rv = (m_io_test->read() & 0x40) << 1;
5656            logerror("TAPE: Read %02x from 0x40%02x - Sense 1?\n",rv,offset);
5757            break;
5858         case 0x002:
59            rv = (ioport("TEST")->read() & 0x20) << 2;
59            rv = (m_io_test->read() & 0x20) << 2;
6060            logerror("TAPE: Read %02x from 0x40%02x - Sense 2?\n",rv,offset);
6161            break;
6262         case 0x003:
63            rv = (ioport("TEST")->read() & 0x10) << 3;
63            rv = (m_io_test->read() & 0x10) << 3;
6464            logerror("TAPE: Read %02x from 0x40%02x - Tape Present\n",rv,offset);
6565            break;
6666         case 0x004:
67            rv = (ioport("TEST")->read() & 0x08) << 4;
67            rv = (m_io_test->read() & 0x08) << 4;
6868            logerror("TAPE: Read %02x from 0x40%02x - Comp (339/1)\n",rv,offset);
6969            break;
7070         case 0x005:
71            rv = (ioport("TEST")->read() & 0x04) << 5;
71            rv = (m_io_test->read() & 0x04) << 5;
7272            logerror("TAPE: Read %02x from 0x40%02x - Clocked Comp (339/13)\n",rv,offset);
7373            break;
7474         case 0x006:
r20997r20998
8888         case 0x060: /* Keyboard Read */
8989            rv = 0xff;
9090            if (m_intvkbd_keyboard_col == 0)
91               rv = ioport("ROW0")->read();
91               rv = m_io_row0->read();
9292            if (m_intvkbd_keyboard_col == 1)
93               rv = ioport("ROW1")->read();
93               rv = m_io_row1->read();
9494            if (m_intvkbd_keyboard_col == 2)
95               rv = ioport("ROW2")->read();
95               rv = m_io_row2->read();
9696            if (m_intvkbd_keyboard_col == 3)
97               rv = ioport("ROW3")->read();
97               rv = m_io_row3->read();
9898            if (m_intvkbd_keyboard_col == 4)
99               rv = ioport("ROW4")->read();
99               rv = m_io_row4->read();
100100            if (m_intvkbd_keyboard_col == 5)
101               rv = ioport("ROW5")->read();
101               rv = m_io_row5->read();
102102            if (m_intvkbd_keyboard_col == 6)
103               rv = ioport("ROW6")->read();
103               rv = m_io_row6->read();
104104            if (m_intvkbd_keyboard_col == 7)
105               rv = ioport("ROW7")->read();
105               rv = m_io_row7->read();
106106            if (m_intvkbd_keyboard_col == 8)
107               rv = ioport("ROW8")->read();
107               rv = m_io_row8->read();
108108            if (m_intvkbd_keyboard_col == 9)
109               rv = ioport("ROW9")->read();
109               rv = m_io_row9->read();
110110            break;
111111         case 0x80:
112112            rv = 0x00;
r20997r20998
338338   {
339339      if (data == 0x2A50)
340340      {
341         membank("bank1")->set_base(machine().root_device().memregion("maincpu")->base() + (0x2000 << 1));
341         m_bank1->set_base(m_region_maincpu->base() + (0x2000 << 1));
342342      }
343343      else if (data == 0x2A51)
344344      {
345         membank("bank1")->set_base(machine().root_device().memregion("ecs_rom")->base() + (0x2000 << 1));
345         m_bank1->set_base(m_region_ecs_rom->base() + (0x2000 << 1));
346346      }
347347   }
348348}
r20997r20998
353353   {
354354      if (data == 0x7A50)
355355      {
356         membank("bank2")->set_base(machine().root_device().memregion("ecs_rom")->base() + (0x7000 << 1)); // ECS ROM at 0x7000 is on page 1
356         m_bank2->set_base(m_region_ecs_rom->base() + (0x7000 << 1)); // ECS ROM at 0x7000 is on page 1
357357      }
358358      else if (data == 0x7A51 )
359359      {
360         membank("bank2")->set_base(machine().root_device().memregion("maincpu")->base() + (0x7000 << 1));
360         m_bank2->set_base(m_region_maincpu->base() + (0x7000 << 1));
361361      }
362362   }
363363}
r20997r20998
368368   {
369369      if (data == 0xEA50)
370370      {
371         membank("bank3")->set_base(machine().root_device().memregion("maincpu")->base() + (0xE000 << 1));
371         m_bank3->set_base(m_region_maincpu->base() + (0xE000 << 1));
372372      }
373373      else if (data == 0xEA51)
374374      {
375         membank("bank3")->set_base(machine().root_device().memregion("ecs_rom")->base() + (0xE000 << 1));
375         m_bank3->set_base(m_region_ecs_rom->base() + (0xE000 << 1));
376376      }
377377   }
378378}
r20997r20998
384384   {
385385      if (data == 0xFA50)
386386      {
387         membank("bank4")->set_base(machine().root_device().memregion("maincpu")->base() + (0xF000 << 1));
387         m_bank4->set_base(m_region_maincpu->base() + (0xF000 << 1));
388388      }
389389      else if (data == 0xFA51)
390390      {
391         membank("bank4")->set_base(machine().root_device().memregion("ecs_rom")->base() + (0xF000 << 1));
391         m_bank4->set_base(m_region_ecs_rom->base() + (0xF000 << 1));
392392      }
393393   }
394394}
395395
396static int intv_load_rom_file(device_image_interface &image)
396int intv_state::intv_load_rom_file(device_image_interface &image)
397397{
398398   int i,j;
399399
r20997r20998
408408   UINT8 high_byte;
409409   UINT8 low_byte;
410410
411   UINT8 *memory = image.device().machine().root_device().memregion("maincpu")->base();
412   intv_state *state = image.device().machine().driver_data<intv_state>();
413   address_space &program = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM);
411   UINT8 *memory = m_region_maincpu->base();
412   address_space &program = m_maincpu->space(AS_PROGRAM);
414413   const char *filetype = image.filetype();
415414
416415   /* if it is in .rom format, we enter here */
r20997r20998
505504            size = ( ram & 0x0f ) * 0x800;
506505
507506            program.install_readwrite_handler(start, start + size,
508               read16_delegate( FUNC( intv_state::intv_cart_ram8_r ), state),
509               write16_delegate( FUNC( intv_state::intv_cart_ram8_w ), state));
507               read16_delegate( FUNC( intv_state::intv_cart_ram8_r ), this),
508               write16_delegate( FUNC( intv_state::intv_cart_ram8_w ), this));
510509         }
511510         /* For now intellivoice always active
512511         if (extra & INTELLIVOICE_MASK)
r20997r20998
553552   {
554553      UINT16 offset[] = {0x4800, 0x5000, 0x6000, 0x7000, 0x9000, 0xa000, 0xc000, 0xd000, 0xf000};
555554      const char* region_name[] = {"4800", "5000", "6000", "7000", "9000", "A000", "C000", "D000", "F000"};
556      UINT8 *memory = image.device().machine().root_device().memregion("maincpu")->base();
557      intv_state *state = image.device().machine().driver_data<intv_state>();
558      address_space &program = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM);
555      UINT8 *memory = m_region_maincpu->base();
556      address_space &program = m_maincpu->space(AS_PROGRAM);
559557
560558      UINT32 size=0;
561559      UINT16 address = 0;
r20997r20998
576574      }
577575      // deal with wsmlb paged rom
578576
579      UINT8 *ecs_rom_region = image.device().machine().root_device().memregion("ecs_rom")->base();
577      UINT8 *ecs_rom_region = m_region_ecs_rom->base();
580578      size = image.get_software_region_length("F000_bank1");
581579      if (size && ecs_rom_region) // only load if ecs is plugged in (should probably be done a different way)
582580      {
r20997r20998
593591      if (size)
594592      {
595593         program.install_readwrite_handler(0xD000, 0xD000 + size,
596            read16_delegate( FUNC( intv_state::intv_cart_ram8_r ), state),
597            write16_delegate( FUNC( intv_state::intv_cart_ram8_w ), state));
594            read16_delegate( FUNC( intv_state::intv_cart_ram8_r ), this),
595            write16_delegate( FUNC( intv_state::intv_cart_ram8_w ), this));
598596      }
599597
600598      size = image.get_software_region_length("8800_RAM8");
601599      if (size)
602600      {
603601         program.install_readwrite_handler(0x8800, 0x8800 + size,
604            read16_delegate( FUNC( intv_state::intv_cart_ram8_r ), state),
605            write16_delegate( FUNC( intv_state::intv_cart_ram8_w ), state));
602            read16_delegate( FUNC( intv_state::intv_cart_ram8_r ), this),
603            write16_delegate( FUNC( intv_state::intv_cart_ram8_w ), this));
606604      }
607605      return IMAGE_INIT_PASS;
608606   }
r20997r20998
617615/* Set Reset and INTR/INTRM Vector */
618616void intv_state::machine_reset()
619617{
620   machine().device("maincpu")->execute().set_input_line_vector(CP1610_RESET, 0x1000);
618   m_maincpu->set_input_line_vector(CP1610_RESET, 0x1000);
621619
622620   /* These are actually the same vector, and INTR is unused */
623   machine().device("maincpu")->execute().set_input_line_vector(CP1610_INT_INTRM, 0x1004);
624   machine().device("maincpu")->execute().set_input_line_vector(CP1610_INT_INTR,  0x1004);
621   m_maincpu->set_input_line_vector(CP1610_INT_INTRM, 0x1004);
622   m_maincpu->set_input_line_vector(CP1610_INT_INTR,  0x1004);
625623
626624   /* Set initial PC */
627   machine().device("maincpu")->state().set_state_int(CP1610_R7, 0x1000);
625   m_maincpu->set_state_int(CP1610_R7, 0x1000);
628626
629627   return;
630628}
631629
632630MACHINE_RESET_MEMBER(intv_state,intvecs)
633631{
634   membank("bank1")->set_base(machine().root_device().memregion("maincpu")->base() + (0x2000 << 1));
635   membank("bank2")->set_base(machine().root_device().memregion("ecs_rom")->base() + (0x7000 << 1));
636   membank("bank3")->set_base(machine().root_device().memregion("maincpu")->base() + (0xE000 << 1));
637   membank("bank4")->set_base(machine().root_device().memregion("maincpu")->base() + (0xF000 << 1));
632   m_bank1->set_base(m_region_maincpu->base() + (0x2000 << 1));
633   m_bank2->set_base(m_region_ecs_rom->base() + (0x7000 << 1));
634   m_bank3->set_base(m_region_maincpu->base() + (0xE000 << 1));
635   m_bank4->set_base(m_region_maincpu->base() + (0xF000 << 1));
638636
639   machine().device("maincpu")->execute().set_input_line_vector(CP1610_RESET, 0x1000);
637   m_maincpu->set_input_line_vector(CP1610_RESET, 0x1000);
640638
641639   /* These are actually the same vector, and INTR is unused */
642   machine().device("maincpu")->execute().set_input_line_vector(CP1610_INT_INTRM, 0x1004);
643   machine().device("maincpu")->execute().set_input_line_vector(CP1610_INT_INTR,  0x1004);
640   m_maincpu->set_input_line_vector(CP1610_INT_INTRM, 0x1004);
641   m_maincpu->set_input_line_vector(CP1610_INT_INTR,  0x1004);
644642
645643   /* Set initial PC */
646   machine().device("maincpu")->state().set_state_int(CP1610_R7, 0x1000);
644   m_maincpu->set_state_int(CP1610_R7, 0x1000);
647645
648646   return;
649647}
r20997r20998
651649
652650TIMER_CALLBACK_MEMBER(intv_state::intv_interrupt_complete)
653651{
654   machine().device("maincpu")->execute().set_input_line(CP1610_INT_INTRM, CLEAR_LINE);
652   m_maincpu->set_input_line(CP1610_INT_INTRM, CLEAR_LINE);
655653   m_bus_copy_mode = 0;
656654}
657655
r20997r20998
670668
671669INTERRUPT_GEN_MEMBER(intv_state::intv_interrupt)
672670{
673   machine().device("maincpu")->execute().set_input_line(CP1610_INT_INTRM, ASSERT_LINE);
671   m_maincpu->set_input_line(CP1610_INT_INTRM, ASSERT_LINE);
674672   m_sr1_int_pending = 1;
675673   m_bus_copy_mode = 1;
676674   m_backtab_row = 0;
677675   UINT8 row;
678   machine().device("maincpu")->execute().adjust_icount(-(12*STIC_ROW_BUSRQ+STIC_FRAME_BUSRQ)); // Account for stic cycle stealing
676   m_maincpu->adjust_icount(-(12*STIC_ROW_BUSRQ+STIC_FRAME_BUSRQ)); // Account for stic cycle stealing
679677   machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")
680678      ->cycles_to_attotime(STIC_VBLANK_END), timer_expired_delegate(FUNC(intv_state::intv_interrupt_complete),this));
681679   for (row=0; row < STIC_BACKTAB_HEIGHT; row++)
682680   {
683      machine().scheduler().timer_set(machine().device<cpu_device>("maincpu")
681      machine().scheduler().timer_set(m_maincpu
684682         ->cycles_to_attotime(STIC_FIRST_FETCH-STIC_FRAME_BUSRQ+STIC_CYCLES_PER_SCANLINE*STIC_Y_SCALE*m_row_delay + (STIC_CYCLES_PER_SCANLINE*STIC_Y_SCALE*STIC_CARD_HEIGHT - STIC_ROW_BUSRQ)*row), timer_expired_delegate(FUNC(intv_state::intv_btb_fill),this));
685683   }
686684
687685   if (m_row_delay == 0)
688686   {
689      machine().device("maincpu")->execute().adjust_icount(-STIC_ROW_BUSRQ); // extra row fetch occurs if vertical delay == 0
687      m_maincpu->adjust_icount(-STIC_ROW_BUSRQ); // extra row fetch occurs if vertical delay == 0
690688   }
691689
692   intv_stic_screenrefresh(machine());
690   intv_stic_screenrefresh();
693691}
694692
695693/* hand 0 == left, 1 == right, 2 == ECS hand controller 1, 3 == ECS hand controller 2 */
696UINT8 intv_control_r(address_space &space, int hand)
694UINT8 intv_state::intv_control_r(int hand)
697695{
698   static const char* const keypad_name[] = { "KEYPAD1", "KEYPAD2", "KEYPAD3", "KEYPAD4" };
696   ioport_port *keypad[] = { m_io_keypad1, m_io_keypad2, m_io_keypad3, m_io_keypad4 };
699697   static const UINT8 keypad_table[] =
700698   {
701699      0xFF, 0x3F, 0x9F, 0x5F, 0xD7, 0xB7, 0x77, 0xDB,
702700      0xBB, 0x7B, 0xDD, 0xBD, 0x7D, 0xDE, 0xBE, 0x7E
703701   };
704702
705   static const char* const disc_name[] = { "DISC1", "DISC2", "DISC3", "DISC4" };
703   ioport_port *disc[] = { m_io_disc1, m_io_disc2, m_io_disc3, m_io_disc4 };
706704   static const UINT8 disc_table[] =
707705   {
708706      0xF3, 0xE3, 0xE7, 0xF7, 0xF6, 0xE6, 0xEE, 0xFE,
709707      0xFC, 0xEC, 0xED, 0xFD, 0xF9, 0xE9, 0xEB, 0xFB
710708   };
711709
712   static const char* const discx_name[] = { "DISCX1", "DISCX2", "DISCX3", "DISCX4" };
713   static const char* const discy_name[] = { "DISCY1", "DISCY2", "DISKY3", "DISCY4" };
710   ioport_port *discx[] = { m_io_discx1, m_io_discx2, m_io_discx3, m_io_discx4 };
711   ioport_port *discy[] = { m_io_discy1, m_io_discy2, m_io_discy3, m_io_discy4 };
714712   static const UINT8 discyx_table[5][5] =
715713   {
716714      { 0xE3, 0xF3, 0xFB, 0xEB, 0xE9 },
r20997r20998
724722   UINT8 rv = 0xFF;
725723
726724   /* keypad */
727   x = space.machine().root_device().ioport(keypad_name[hand])->read();
725   x = keypad[hand]->read();
728726   for (y = 0; y < 16; y++)
729727   {
730728      if (x & (1 << y))
r20997r20998
733731      }
734732   }
735733
736   switch ((space.machine().root_device().ioport("OPTIONS")->read() >> hand) & 1)
734   switch ((m_io_options->read() >> hand) & 1)
737735   {
738736      case 0: /* disc == digital */
739737      default:
740738
741         x = space.machine().root_device().ioport(disc_name[hand])->read();
739         x = disc[hand]->read();
742740         for (y = 0; y < 16; y++)
743741         {
744742            if (x & (1 << y))
r20997r20998
750748
751749      case 1: /* disc == _fake_ analog */
752750
753         x = space.machine().root_device().ioport(discx_name[hand])->read();
754         y = space.machine().root_device().ioport(discy_name[hand])->read();
751         x = discx[hand]->read();
752         y = discy[hand]->read();
755753         rv &= discyx_table[y / 32][x / 32];
756754   }
757755
r20997r20998
760758
761759READ8_MEMBER( intv_state::intv_left_control_r )
762760{
763   return intv_control_r(space, 0);
761   return intv_control_r(0);
764762}
765763
766764READ8_MEMBER( intv_state::intv_right_control_r )
767765{
768   return intv_control_r(space, 1);
766   return intv_control_r(1);
769767}
770768
771769READ8_MEMBER( intv_state::intv_ecs_porta_r )
772770{
773   if (ioport("ECS_CNTRLSEL")->read() == 0)
774      return intv_control_r(space, 2);
771   if (m_io_ecs_cntrlsel->read() == 0)
772      return intv_control_r(2);
775773   else
776774      return 0xff; // not sure what to return here, maybe it should be last output?
777775}
778776
779777READ8_MEMBER( intv_state::intv_ecs_portb_r )
780778{
781   switch (ioport("ECS_CNTRLSEL")->read())
779   switch (m_io_ecs_cntrlsel->read())
782780   {
783781      case 0x00: // hand controller
784782      {
785         return intv_control_r(space, 3);
783         return intv_control_r(3);
786784      }
787785      case 0x01: // synthesizer keyboard
788786      {
789         static const char* const ecs_synth_rows[] = { "ECS_SYNTH_ROW0", "ECS_SYNTH_ROW1", "ECS_SYNTH_ROW2", "ECS_SYNTH_ROW3", "ECS_SYNTH_ROW4", "ECS_SYNTH_ROW5", "ECS_SYNTH_ROW6" };
787         ioport_port *ecs_synth_rows[] = { m_io_ecs_synth_row0, m_io_ecs_synth_row1, m_io_ecs_synth_row2, m_io_ecs_synth_row3, m_io_ecs_synth_row4, m_io_ecs_synth_row5, m_io_ecs_synth_row6 };
790788         UINT8 rv = 0xFF;
791789         // return correct result if more than one bit of 0xFE is set
792790         for (int i=0; i<7; i++)
793791         {
794792         if (m_ecs_psg_porta & (1<<i))
795            rv &= ioport(ecs_synth_rows[i])->read();
793            rv &= ecs_synth_rows[i]->read();
796794         }
797795         return rv;
798796      }
799797      case 0x02: // ecs keyboard
800798      {
801         static const char* const ecs_keyboard_rows[] = { "ECS_ROW0", "ECS_ROW1", "ECS_ROW2", "ECS_ROW3", "ECS_ROW4", "ECS_ROW5", "ECS_ROW6" };
799         ioport_port *ecs_keyboard_rows[] = { m_io_ecs_row0, m_io_ecs_row1, m_io_ecs_row2, m_io_ecs_row3, m_io_ecs_row4, m_io_ecs_row5, m_io_ecs_row6 };
802800         UINT8 rv = 0xFF;
803801         // return correct result if more than one bit of 0xFE is set
804802         for (int i=0; i<7; i++)
805803         {
806804         if (m_ecs_psg_porta & (1<<i))
807            rv &= ioport(ecs_keyboard_rows[i])->read();
805            rv &= ecs_keyboard_rows[i]->read();
808806         }
809807         return rv;
810808      }
r20997r20998
826824   {
827825      /* First, initialize these as empty so that the intellivision
828826       * will think that the playcable is not attached */
829      UINT8 *memory = image.device().machine().root_device().memregion("maincpu")->base();
827      UINT8 *memory = m_region_maincpu->base();
830828
831829      /* assume playcable is absent */
832830      memory[0x4800 << 1] = 0xff;
r20997r20998
837835
838836   if (strcmp(image.device().tag(),":cart2") == 0) /* Keyboard component cartridge slot */
839837   {
840      UINT8 *memory = image.device().machine().root_device().memregion("keyboard")->base();
838      UINT8 *memory = m_region_keyboard->base();
841839
842840      /* Assume an 8K cart, like BASIC */
843841      image.fread( &memory[0xe000], 0x2000);
trunk/src/mess/includes/intv.h
r20997r20998
3434{
3535public:
3636   intv_state(const machine_config &mconfig, device_type type, const char *tag)
37      : driver_device(mconfig, type, tag),
38   m_maincpu(*this, "maincpu"),
39   m_intellivoice(*this, "sp0256_speech"),
40   m_sound(*this, "ay8914.1"),
41   m_ecs_sound(*this, "ay8914.2"),
42   m_intvkbd_dualport_ram(*this, "dualport_ram"),
43   m_videoram(*this, "videoram"),
44   m_keyboard(*this, "keyboard")
37      : driver_device(mconfig, type, tag)
38      , m_maincpu(*this, "maincpu")
39      , m_intellivoice(*this, "sp0256_speech")
40      , m_sound(*this, "ay8914.1")
41      , m_ecs_sound(*this, "ay8914.2")
42      , m_intvkbd_dualport_ram(*this, "dualport_ram")
43      , m_videoram(*this, "videoram")
44      , m_keyboard(*this, "keyboard")
45      , m_region_maincpu(*this, "maincpu")
46      , m_region_ecs_rom(*this, "ecs_rom")
47      , m_region_keyboard(*this, "keyboard")
48      , m_bank1(*this, "bank1")
49      , m_bank2(*this, "bank2")
50      , m_bank3(*this, "bank3")
51      , m_bank4(*this, "bank4")
52      , m_io_keypad1(*this, "KEYPAD1")
53      , m_io_disc1(*this, "DISC1")
54      , m_io_discx1(*this, "DISCX1")
55      , m_io_discy1(*this, "DISCY1")
56      , m_io_keypad2(*this, "KEYPAD2")
57      , m_io_disc2(*this, "DISC2")
58      , m_io_discx2(*this, "DISCX2")
59      , m_io_discy2(*this, "DISCY2")
60      , m_io_options(*this, "OPTIONS")
61      , m_io_ecs_row0(*this, "ECS_ROW0")
62      , m_io_ecs_row1(*this, "ECS_ROW1")
63      , m_io_ecs_row2(*this, "ECS_ROW2")
64      , m_io_ecs_row3(*this, "ECS_ROW3")
65      , m_io_ecs_row4(*this, "ECS_ROW4")
66      , m_io_ecs_row5(*this, "ECS_ROW5")
67      , m_io_ecs_row6(*this, "ECS_ROW6")
68      , m_io_ecs_synth_row0(*this, "ECS_SYNTH_ROW0")
69      , m_io_ecs_synth_row1(*this, "ECS_SYNTH_ROW1")
70      , m_io_ecs_synth_row2(*this, "ECS_SYNTH_ROW2")
71      , m_io_ecs_synth_row3(*this, "ECS_SYNTH_ROW3")
72      , m_io_ecs_synth_row4(*this, "ECS_SYNTH_ROW4")
73      , m_io_ecs_synth_row5(*this, "ECS_SYNTH_ROW5")
74      , m_io_ecs_synth_row6(*this, "ECS_SYNTH_ROW6")
75      , m_io_keypad3(*this, "KEYPAD3")
76      , m_io_disc3(*this, "DISC3")
77      , m_io_discx3(*this, "DISCX3")
78      , m_io_discy3(*this, "DISCY3")
79      , m_io_keypad4(*this, "KEYPAD4")
80      , m_io_disc4(*this, "DISC4")
81      , m_io_discx4(*this, "DISCX4")
82      , m_io_discy4(*this, "DISCY4")
83      , m_io_ecs_cntrlsel(*this, "ECS_CNTRLSEL")
84      , m_io_row0(*this, "ROW0")
85      , m_io_row1(*this, "ROW1")
86      , m_io_row2(*this, "ROW2")
87      , m_io_row3(*this, "ROW3")
88      , m_io_row4(*this, "ROW4")
89      , m_io_row5(*this, "ROW5")
90      , m_io_row6(*this, "ROW6")
91      , m_io_row7(*this, "ROW7")
92      , m_io_row8(*this, "ROW8")
93      , m_io_row9(*this, "ROW9")
94      , m_io_test(*this, "TEST")
4595   { }
4696
4797   required_device<cpu_device> m_maincpu;
r20997r20998
146196
147197protected:
148198   optional_device<cpu_device> m_keyboard;
199   required_memory_region m_region_maincpu;
200   optional_memory_region m_region_ecs_rom;
201   optional_memory_region m_region_keyboard;
202   optional_memory_bank m_bank1;
203   optional_memory_bank m_bank2;
204   optional_memory_bank m_bank3;
205   optional_memory_bank m_bank4;
206   required_ioport m_io_keypad1;
207   required_ioport m_io_disc1;
208   required_ioport m_io_discx1;
209   required_ioport m_io_discy1;
210   required_ioport m_io_keypad2;
211   required_ioport m_io_disc2;
212   required_ioport m_io_discx2;
213   required_ioport m_io_discy2;
214   required_ioport m_io_options;
215   optional_ioport m_io_ecs_row0;
216   optional_ioport m_io_ecs_row1;
217   optional_ioport m_io_ecs_row2;
218   optional_ioport m_io_ecs_row3;
219   optional_ioport m_io_ecs_row4;
220   optional_ioport m_io_ecs_row5;
221   optional_ioport m_io_ecs_row6;
222   optional_ioport m_io_ecs_synth_row0;
223   optional_ioport m_io_ecs_synth_row1;
224   optional_ioport m_io_ecs_synth_row2;
225   optional_ioport m_io_ecs_synth_row3;
226   optional_ioport m_io_ecs_synth_row4;
227   optional_ioport m_io_ecs_synth_row5;
228   optional_ioport m_io_ecs_synth_row6;
229   optional_ioport m_io_keypad3;
230   optional_ioport m_io_disc3;
231   optional_ioport m_io_discx3;
232   optional_ioport m_io_discy3;
233   optional_ioport m_io_keypad4;
234   optional_ioport m_io_disc4;
235   optional_ioport m_io_discx4;
236   optional_ioport m_io_discy4;
237   optional_ioport m_io_ecs_cntrlsel;
238   optional_ioport m_io_row0;
239   optional_ioport m_io_row1;
240   optional_ioport m_io_row2;
241   optional_ioport m_io_row3;
242   optional_ioport m_io_row4;
243   optional_ioport m_io_row5;
244   optional_ioport m_io_row6;
245   optional_ioport m_io_row7;
246   optional_ioport m_io_row8;
247   optional_ioport m_io_row9;
248   optional_ioport m_io_test;
249
250   int intv_load_rom_file(device_image_interface &image);
251   UINT8 intv_control_r(int hand);
252   void intv_set_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color);
253   UINT32 intv_get_pixel(bitmap_ind16 &bitmap, int x, int y);
254   void intv_plot_box(bitmap_ind16 &bm, int x, int y, int w, int h, int color);
255   int sprites_collide(int spriteNum1, int spriteNum2);
256   void determine_sprite_collisions();
257   void render_sprites();
258   void render_line(bitmap_ind16 &bitmap, UINT8 nextByte, UINT16 x, UINT16 y, UINT8 fgcolor, UINT8 bgcolor);
259   void render_colored_squares(bitmap_ind16 &bitmap, UINT16 x, UINT16 y, UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3);
260   void render_color_stack_mode(bitmap_ind16 &bitmap);
261   void render_fg_bg_mode(bitmap_ind16 &bitmap);
262   void copy_sprites_to_background(bitmap_ind16 &bitmap);
263   void render_background(bitmap_ind16 &bitmap);
264   void draw_borders(bitmap_ind16 &bm);
265   void intv_stic_screenrefresh();
149266};
150267
151/*----------- defined in video/intv.c -----------*/
152void intv_stic_screenrefresh(running_machine &machine);
153
154
155268#endif /* INTV_H_ */
trunk/src/mess/video/intv.c
r20997r20998
1010
1111/* initialized to non-zero, because we divide by it */
1212
13INLINE void intv_set_pixel(intv_state *state, bitmap_ind16 &bitmap, int x, int y, UINT32 color)
13void intv_state::intv_set_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color)
1414{
1515   int w, h;
1616
1717   // output scaling
18   x *= state->m_x_scale;
19   y *= state->m_y_scale;
18   x *= m_x_scale;
19   y *= m_y_scale;
2020   color = SET_COLOR(color);
2121
22   for (h = 0; h < state->m_y_scale; h++)
23      for (w = 0; w < state->m_x_scale; w++)
22   for (h = 0; h < m_y_scale; h++)
23      for (w = 0; w < m_x_scale; w++)
2424         bitmap.pix16(y + h, x + w) = color;
2525}
2626
27INLINE UINT32 intv_get_pixel(intv_state *state, bitmap_ind16 &bitmap, int x, int y)
27UINT32 intv_state::intv_get_pixel(bitmap_ind16 &bitmap, int x, int y)
2828{
29   return GET_COLOR(bitmap.pix16(y * state->m_y_scale, x * state->m_x_scale));
29   return GET_COLOR(bitmap.pix16(y * m_y_scale, x * m_x_scale));
3030}
3131
32INLINE void intv_plot_box(intv_state *state, bitmap_ind16 &bm, int x, int y, int w, int h, int color)
32void intv_state::intv_plot_box(bitmap_ind16 &bm, int x, int y, int w, int h, int color)
3333{
34   bm.plot_box(x * state->m_x_scale, y * state->m_y_scale, w * state->m_x_scale, h * state->m_y_scale, SET_COLOR(color));
34   bm.plot_box(x * m_x_scale, y * m_y_scale, w * m_x_scale, h * m_y_scale, SET_COLOR(color));
3535}
3636
3737void intv_state::video_start()
r20997r20998
9393}
9494
9595
96static int sprites_collide(intv_state *state, int spriteNum1, int spriteNum2)
96int intv_state::sprites_collide(int spriteNum1, int spriteNum2)
9797{
9898   INT16 x0, y0, w0, h0, x1, y1, w1, h1, x2, y2, w2, h2;
9999
100   intv_sprite_type* s1 = &state->m_sprite[spriteNum1];
101   intv_sprite_type* s2 = &state->m_sprite[spriteNum2];
100   intv_sprite_type* s1 = &m_sprite[spriteNum1];
101   intv_sprite_type* s2 = &m_sprite[spriteNum2];
102102
103   x0 = STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay - STIC_CARD_WIDTH;
104   y0 = STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay - STIC_CARD_HEIGHT;
103   x0 = STIC_OVERSCAN_LEFT_WIDTH + m_col_delay - STIC_CARD_WIDTH;
104   y0 = STIC_OVERSCAN_TOP_HEIGHT + m_row_delay - STIC_CARD_HEIGHT;
105105   x1 = (s1->xpos + x0) * STIC_X_SCALE; y1 = (s1->ypos + y0) * STIC_Y_SCALE;
106106   x2 = (s2->xpos + x0) * STIC_X_SCALE; y2 = (s2->ypos + y0) * STIC_Y_SCALE;
107107   w1 = (s1->doublex ? 2 : 1) * STIC_CARD_WIDTH;
r20997r20998
126126   {
127127      for (y0 = 0; y0 < h0; y0++)
128128      {
129         if (state->m_sprite_buffers[spriteNum1][x0 + x1][y0 + y1] &&
130            state->m_sprite_buffers[spriteNum2][x0 + x2][y0 + y2])
129         if (m_sprite_buffers[spriteNum1][x0 + x1][y0 + y1] &&
130            m_sprite_buffers[spriteNum2][x0 + x2][y0 + y2])
131131            return TRUE;
132132      }
133133   }
r20997r20998
135135   return FALSE;
136136}
137137
138static void determine_sprite_collisions(intv_state *state)
138void intv_state::determine_sprite_collisions()
139139{
140140   // check sprite to sprite collisions
141141   int i, j;
142142   for (i = 0; i < STIC_MOBS - 1; i++)
143143   {
144      intv_sprite_type* s1 = &state->m_sprite[i];
144      intv_sprite_type* s1 = &m_sprite[i];
145145      if (s1->xpos == 0 || !s1->coll)
146146         continue;
147147
148148      for (j = i + 1; j < STIC_MOBS; j++)
149149      {
150         intv_sprite_type* s2 = &state->m_sprite[j];
150         intv_sprite_type* s2 = &m_sprite[j];
151151         if (s2->xpos == 0 || !s2->coll)
152152            continue;
153153
154         if (sprites_collide(state, i, j))
154         if (sprites_collide(i, j))
155155         {
156156            s1->collision |= (1 << j);
157157            s2->collision |= (1 << i);
r20997r20998
160160   }
161161}
162162
163static void render_sprites(running_machine &machine)
163void intv_state::render_sprites()
164164{
165   intv_state *state = machine.driver_data<intv_state>();
166165   INT32 cardMemoryLocation, pixelSize;
167166   INT32 spritePixelHeight;
168167   INT32 nextMemoryLocation;
r20997r20998
172171   INT32 xInc;
173172   INT32 i, j, k;
174173
175   UINT8* memory = state->memregion("maincpu")->base();
174   UINT8* memory = m_region_maincpu->base();
176175
177176   for (i = 0; i < STIC_MOBS; i++)
178177   {
179      intv_sprite_type* s = &state->m_sprite[i];
178      intv_sprite_type* s = &m_sprite[i];
180179
181180      if (s->grom)
182181         cardMemoryLocation = (s->card * STIC_CARD_HEIGHT);
r20997r20998
192191         if (s->grom)
193192            nextData = memory[(0x3000+nextMemoryLocation)<<1];
194193         else if (nextMemoryLocation < 0x200)
195            nextData = state->m_gram[nextMemoryLocation];
194            nextData = m_gram[nextMemoryLocation];
196195         else
197196            nextData = 0xFFFF;
198197         nextX = (s->xflip ? ((s->doublex ? 2 : 1) * STIC_CARD_WIDTH - 1) : 0);
r20997r20998
201200
202201         for (k = 0; k < STIC_CARD_WIDTH * (1 + s->doublex); k++)
203202         {
204            state->m_sprite_buffers[i][nextX + k * xInc][nextY] = (nextData & (1 << ((STIC_CARD_WIDTH - 1) - k / (1 + s->doublex)))) != 0;
203            m_sprite_buffers[i][nextX + k * xInc][nextY] = (nextData & (1 << ((STIC_CARD_WIDTH - 1) - k / (1 + s->doublex)))) != 0;
205204         }
206205      }
207206   }
208207}
209208
210static void render_line(running_machine &machine, bitmap_ind16 &bitmap,
211   UINT8 nextByte, UINT16 x, UINT16 y, UINT8 fgcolor, UINT8 bgcolor)
209void intv_state::render_line(bitmap_ind16 &bitmap, UINT8 nextByte, UINT16 x, UINT16 y, UINT8 fgcolor, UINT8 bgcolor)
212210{
213   intv_state *state = machine.driver_data<intv_state>();
214211   UINT32 color;
215212   UINT8 i;
216213
217214   for (i = 0; i < STIC_CARD_WIDTH; i++)
218215   {
219216      color = (nextByte & (1 << ((STIC_CARD_WIDTH - 1) - i)) ? fgcolor : bgcolor);
220      intv_set_pixel(state, bitmap, x+i, y, color);
221      intv_set_pixel(state, bitmap, x+i, y+1, color);
217      intv_set_pixel(bitmap, x+i, y, color);
218      intv_set_pixel(bitmap, x+i, y+1, color);
222219   }
223220}
224221
225static void render_colored_squares(running_machine &machine, bitmap_ind16 &bitmap,
226   UINT16 x, UINT16 y, UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3)
222void intv_state::render_colored_squares(bitmap_ind16 &bitmap, UINT16 x, UINT16 y, UINT8 color0, UINT8 color1, UINT8 color2, UINT8 color3)
227223{
228   intv_state *state = machine.driver_data<intv_state>();
229
230   intv_plot_box(state, bitmap, x, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color0);
231   intv_plot_box(state, bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color1);
232   intv_plot_box(state, bitmap, x, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color2);
233   intv_plot_box(state, bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color3);
224   intv_plot_box(bitmap, x, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color0);
225   intv_plot_box(bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color1);
226   intv_plot_box(bitmap, x, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color2);
227   intv_plot_box(bitmap, x + STIC_CSQM_WIDTH * STIC_X_SCALE, y + STIC_CSQM_HEIGHT * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, color3);
234228}
235229
236static void render_color_stack_mode(running_machine &machine, bitmap_ind16 &bitmap)
230void intv_state::render_color_stack_mode(bitmap_ind16 &bitmap)
237231{
238   intv_state *state = machine.driver_data<intv_state>();
239232   INT16 w, h, nextx, nexty;
240233   UINT8 csPtr = 0;
241234   UINT16 nextCard;
242   UINT8 *ram = state->memregion("maincpu")->base();
235   UINT8 *ram = m_region_maincpu->base();
243236
244   for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay) * STIC_Y_SCALE;
237   for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + m_row_delay) * STIC_Y_SCALE;
245238         h < STIC_BACKTAB_HEIGHT;
246239         h++, nexty += STIC_CARD_HEIGHT * STIC_Y_SCALE)
247240   {
248      for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay) * STIC_X_SCALE;
241      for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + m_col_delay) * STIC_X_SCALE;
249242            w < STIC_BACKTAB_WIDTH;
250243            w++, nextx += STIC_CARD_WIDTH * STIC_X_SCALE)
251244      {
252         nextCard = state->m_backtab_buffer[h][w];
245         nextCard = m_backtab_buffer[h][w];
253246
254247         // colored squares mode
255248         if ((nextCard & (STIC_CSTM_FG3|STIC_CSTM_SEL)) == STIC_CSTM_FG3)
256249         {
257            UINT8 csColor = state->m_stic_registers[STIC_CSR + csPtr];
250            UINT8 csColor = m_stic_registers[STIC_CSR + csPtr];
258251            UINT8 color0 = nextCard & STIC_CSQM_A;
259252            UINT8 color1 = (nextCard & STIC_CSQM_B) >> 3;
260253            UINT8 color2 = (nextCard & STIC_CSQM_C) >> 6;
261254            UINT8 color3 = ((nextCard & STIC_CSQM_D2) >> 11) |
262255                  ((nextCard & (STIC_CSQM_D10)) >> 9);
263            render_colored_squares(machine, bitmap, nextx, nexty,
256            render_colored_squares(bitmap, nextx, nexty,
264257                  (color0 == 7 ? csColor : (color0 | FOREGROUND_BIT)),
265258                  (color1 == 7 ? csColor : (color1 | FOREGROUND_BIT)),
266259                  (color2 == 7 ? csColor : (color2 | FOREGROUND_BIT)),
r20997r20998
279272
280273            fgcolor = ((nextCard & STIC_CSTM_FG3) >> 9) |
281274                  (nextCard & (STIC_CSTM_FG20)) | FOREGROUND_BIT;
282            bgcolor = state->m_stic_registers[STIC_CSR + csPtr] & STIC_CSR_BG;
275            bgcolor = m_stic_registers[STIC_CSR + csPtr] & STIC_CSR_BG;
283276
284277            isGrom = !(nextCard & STIC_CSTM_SEL);
285278            if (isGrom)
r20997r20998
287280               memoryLocation = 0x3000 + (nextCard & STIC_CSTM_C);
288281               memory = ram;
289282               for (j = 0; j < STIC_CARD_HEIGHT; j++)
290                  render_line(machine, bitmap, memory[(memoryLocation + j) * 2],
283                  render_line(bitmap, memory[(memoryLocation + j) * 2],
291284                     nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
292285            }
293286            else
294287            {
295288               memoryLocation = (nextCard & STIC_CSTM_C50);
296               memory = state->m_gram;
289               memory = m_gram;
297290               for (j = 0; j < STIC_CARD_HEIGHT; j++)
298                  render_line(machine, bitmap, memory[memoryLocation + j],
291                  render_line(bitmap, memory[memoryLocation + j],
299292                        nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
300293            }
301294         }
r20997r20998
303296   }
304297}
305298
306static void render_fg_bg_mode(running_machine &machine, bitmap_ind16 &bitmap)
299void intv_state::render_fg_bg_mode(bitmap_ind16 &bitmap)
307300{
308   intv_state *state = machine.driver_data<intv_state>();
309301   INT16 w, h, nextx, nexty;
310302   UINT8 j, isGrom, fgcolor, bgcolor;
311303   UINT16 nextCard, memoryLocation;
312304   UINT8* memory;
313   UINT8* ram = state->memregion("maincpu")->base();
305   UINT8* ram = m_region_maincpu->base();
314306
315   for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay) * STIC_Y_SCALE;
307   for (h = 0, nexty = (STIC_OVERSCAN_TOP_HEIGHT + m_row_delay) * STIC_Y_SCALE;
316308         h < STIC_BACKTAB_HEIGHT;
317309         h++, nexty += STIC_CARD_HEIGHT * STIC_Y_SCALE)
318310   {
319      for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay) * STIC_X_SCALE;
311      for (w = 0, nextx = (STIC_OVERSCAN_LEFT_WIDTH + m_col_delay) * STIC_X_SCALE;
320312            w < STIC_BACKTAB_WIDTH;
321313            w++, nextx += STIC_CARD_WIDTH * STIC_X_SCALE)
322314      {
323         nextCard = state->m_backtab_buffer[h][w];
315         nextCard = m_backtab_buffer[h][w];
324316         fgcolor = (nextCard & STIC_FBM_FG) | FOREGROUND_BIT;
325317         bgcolor = ((nextCard & STIC_FBM_BG2) >> 11) |
326318               ((nextCard & STIC_FBM_BG310) >> 9);
r20997r20998
331323            memoryLocation = 0x3000 + (nextCard & STIC_FBM_C);
332324            memory = ram;
333325            for (j = 0; j < STIC_CARD_HEIGHT; j++)
334               render_line(machine, bitmap, memory[(memoryLocation + j) * 2],
326               render_line(bitmap, memory[(memoryLocation + j) * 2],
335327                     nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
336328         }
337329         else
338330         {
339331            memoryLocation = (nextCard & STIC_FBM_C);
340            memory = state->m_gram;
332            memory = m_gram;
341333            for (j = 0; j < STIC_CARD_HEIGHT; j++)
342               render_line(machine, bitmap, memory[memoryLocation + j],
334               render_line(bitmap, memory[memoryLocation + j],
343335                     nextx, nexty + j * STIC_Y_SCALE, fgcolor, bgcolor);
344336         }
345337      }
346338   }
347339}
348340
349static void copy_sprites_to_background(running_machine &machine, bitmap_ind16 &bitmap)
341void intv_state::copy_sprites_to_background(bitmap_ind16 &bitmap)
350342{
351   intv_state *state = machine.driver_data<intv_state>();
352343   UINT8 width, currentPixel;
353344   UINT8 borderCollision, foregroundCollision;
354345   UINT8 spritePixelHeight, x, y;
r20997r20998
358349
359350   for (i = STIC_MOBS - 1; i >= 0; i--)
360351   {
361      intv_sprite_type *s = &state->m_sprite[i];
352      intv_sprite_type *s = &m_sprite[i];
362353      if (s->xpos == 0 || (!s->coll && !s->visible))
363354         continue;
364355
r20997r20998
368359      spritePixelHeight = (s->quady ? 4 : 1) * (s->doubley ? 2 : 1) * (s->doubleyres ? 2 : 1) * STIC_CARD_HEIGHT;
369360      width = (s->doublex ? 2 : 1) * STIC_CARD_WIDTH;
370361
371      leftX = (s->xpos - STIC_CARD_WIDTH + STIC_OVERSCAN_LEFT_WIDTH + state->m_col_delay) * STIC_X_SCALE;
372      nextY = (s->ypos - STIC_CARD_HEIGHT + STIC_OVERSCAN_TOP_HEIGHT + state->m_row_delay) * STIC_Y_SCALE;
362      leftX = (s->xpos - STIC_CARD_WIDTH + STIC_OVERSCAN_LEFT_WIDTH + m_col_delay) * STIC_X_SCALE;
363      nextY = (s->ypos - STIC_CARD_HEIGHT + STIC_OVERSCAN_TOP_HEIGHT + m_row_delay) * STIC_Y_SCALE;
373364
374      leftBorder =  (STIC_OVERSCAN_LEFT_WIDTH + (state->m_left_edge_inhibit ? STIC_CARD_WIDTH : 0)) * STIC_X_SCALE;
365      leftBorder =  (STIC_OVERSCAN_LEFT_WIDTH + (m_left_edge_inhibit ? STIC_CARD_WIDTH : 0)) * STIC_X_SCALE;
375366      rightBorder = (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 - 1) * STIC_X_SCALE;
376      topBorder = (STIC_OVERSCAN_TOP_HEIGHT + (state->m_top_edge_inhibit ? STIC_CARD_HEIGHT : 0)) * STIC_Y_SCALE;
367      topBorder = (STIC_OVERSCAN_TOP_HEIGHT + (m_top_edge_inhibit ? STIC_CARD_HEIGHT : 0)) * STIC_Y_SCALE;
377368      bottomBorder = (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT) * STIC_Y_SCALE - 1;
378369
379370      for (y = 0; y < spritePixelHeight; y++)
r20997r20998
381372         for (x = 0; x < width; x++)
382373         {
383374            //if this sprite pixel is not on, then don't paint it
384            if (!state->m_sprite_buffers[i][x][y])
375            if (!m_sprite_buffers[i][x][y])
385376               continue;
386377
387378            nextX = leftX + x;
r20997r20998
394385               continue;
395386            }
396387
397            currentPixel = intv_get_pixel(state, bitmap, nextX, nextY);
388            currentPixel = intv_get_pixel(bitmap, nextX, nextY);
398389
399390            //check for foreground collision
400391            if (currentPixel & FOREGROUND_BIT)
r20997r20998
406397
407398            if (s->visible)
408399            {
409               intv_set_pixel(state, bitmap, nextX, nextY, s->color | (currentPixel & FOREGROUND_BIT));
400               intv_set_pixel(bitmap, nextX, nextY, s->color | (currentPixel & FOREGROUND_BIT));
410401            }
411402         }
412403         nextY++;
r20997r20998
423414   }
424415}
425416
426static void render_background(running_machine &machine, bitmap_ind16 &bitmap)
417void intv_state::render_background(bitmap_ind16 &bitmap)
427418{
428   intv_state *state = machine.driver_data<intv_state>();
429   if (state->m_color_stack_mode)
430      render_color_stack_mode(machine, bitmap);
419   if (m_color_stack_mode)
420      render_color_stack_mode(bitmap);
431421   else
432      render_fg_bg_mode(machine, bitmap);
422      render_fg_bg_mode(bitmap);
433423}
434424
435425#ifdef UNUSED_CODE
r20997r20998
478468               if (colorb == 7) colorb = state->m_stic_registers[STIC_CSR + STIC_CSR3];
479469               if (colorc == 7) colorc = state->m_stic_registers[STIC_CSR + STIC_CSR3];
480470               if (colord == 7) colord = state->m_stic_registers[STIC_CSR + STIC_CSR3];
481               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colora);
482               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH)) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorb);
483               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorc);
484               intv_plot_box(state, bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colord);
471               intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colora);
472               intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH)) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorb);
473               intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colorc);
474               intv_plot_box(bitmap, (x0 + col * STIC_CARD_WIDTH + STIC_CSQM_WIDTH) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + STIC_CSQM_HEIGHT) * STIC_Y_SCALE, STIC_CSQM_WIDTH * STIC_X_SCALE, STIC_CSQM_HEIGHT * STIC_Y_SCALE, colord);
485475            }
486476            else // normal color stack mode
487477            {
r20997r20998
519509
520510                  for(j=0;j<8;j++)
521511                  {
522                     //intv_set_pixel(state, bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 1);
512                     //intv_set_pixel(bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 1);
523513                  }
524514
525515               }
r20997r20998
533523
534524                  for(j=0;j<8;j++)
535525                  {
536                     //intv_set_pixel(state, bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 2);
526                     //intv_set_pixel(bitmap, (x0 + col * STIC_CARD_WIDTH + j) * STIC_X_SCALE, (y0 + row * STIC_CARD_HEIGHT + 7) * STIC_Y_SCALE + 1, 2);
537527                  }
538528               }
539529            }
r20997r20998
685675}
686676#endif
687677
688static void draw_borders(running_machine &machine, bitmap_ind16 &bm)
678void intv_state::draw_borders(bitmap_ind16 &bm)
689679{
690   intv_state *state = machine.driver_data<intv_state>();
680   intv_plot_box(bm, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + (m_left_edge_inhibit ? STIC_CARD_WIDTH : m_col_delay)) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, m_border_color);
681   intv_plot_box(bm, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1) * STIC_X_SCALE, 0, STIC_OVERSCAN_RIGHT_WIDTH, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, m_border_color);
691682
692   intv_plot_box(state, bm, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + (state->m_left_edge_inhibit ? STIC_CARD_WIDTH : state->m_col_delay)) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, state->m_border_color);
693   intv_plot_box(state, bm, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1) * STIC_X_SCALE, 0, STIC_OVERSCAN_RIGHT_WIDTH, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT + STIC_OVERSCAN_BOTTOM_HEIGHT) * STIC_Y_SCALE, state->m_border_color);
694
695   intv_plot_box(state, bm, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + (state->m_top_edge_inhibit ? STIC_CARD_HEIGHT : state->m_row_delay)) * STIC_Y_SCALE, state->m_border_color);
696   intv_plot_box(state, bm, 0, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT) * STIC_Y_SCALE, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, STIC_OVERSCAN_BOTTOM_HEIGHT * STIC_Y_SCALE, state->m_border_color);
683   intv_plot_box(bm, 0, 0, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, (STIC_OVERSCAN_TOP_HEIGHT + (m_top_edge_inhibit ? STIC_CARD_HEIGHT : m_row_delay)) * STIC_Y_SCALE, m_border_color);
684   intv_plot_box(bm, 0, (STIC_OVERSCAN_TOP_HEIGHT + STIC_BACKTAB_HEIGHT * STIC_CARD_HEIGHT) * STIC_Y_SCALE, (STIC_OVERSCAN_LEFT_WIDTH + STIC_BACKTAB_WIDTH * STIC_CARD_WIDTH - 1 + STIC_OVERSCAN_RIGHT_WIDTH) * STIC_X_SCALE, STIC_OVERSCAN_BOTTOM_HEIGHT * STIC_Y_SCALE, m_border_color);
697685}
698686
699void intv_stic_screenrefresh(running_machine &machine)
687void intv_state::intv_stic_screenrefresh()
700688{
701   intv_state *state = machine.driver_data<intv_state>();
702689   int i;
703690
704   if (state->m_stic_handshake != 0)
691   if (m_stic_handshake != 0)
705692   {
706      state->m_stic_handshake = 0;
693      m_stic_handshake = 0;
707694      // Render the background
708      render_background(machine, state->m_bitmap);
695      render_background(m_bitmap);
709696      // Render the sprites into their buffers
710      render_sprites(machine);
711      for (i = 0; i < STIC_MOBS; i++) state->m_sprite[i].collision = 0;
697      render_sprites();
698      for (i = 0; i < STIC_MOBS; i++) m_sprite[i].collision = 0;
712699      // Copy the sprites to the background
713      copy_sprites_to_background(machine, state->m_bitmap);
714      determine_sprite_collisions(state);
715      for (i = 0; i < STIC_MOBS; i++) state->m_stic_registers[STIC_MCR + i] |= state->m_sprite[i].collision;
700      copy_sprites_to_background(m_bitmap);
701      determine_sprite_collisions();
702      for (i = 0; i < STIC_MOBS; i++) m_stic_registers[STIC_MCR + i] |= m_sprite[i].collision;
716703      /* draw the screen borders if enabled */
717      draw_borders(machine, state->m_bitmap);
704      draw_borders(m_bitmap);
718705   }
719706   else
720707   {
721708      /* STIC disabled, just fill with border color */
722      state->m_bitmap.fill(SET_COLOR(state->m_border_color));
709      m_bitmap.fill(SET_COLOR(m_border_color));
723710   }
724711}
725712
r20997r20998
729716
730717   READ8_MEMBER( intv_state::intvkbd_tms9927_r )
731718{
732   //intv_state *state = space.machine().driver_data<intv_state>();
733719   UINT8 rv;
734720   switch (offset)
735721   {
r20997r20998
752738
753739WRITE8_MEMBER( intv_state::intvkbd_tms9927_w )
754740{
755   //intv_state *state = space.machine().driver_data<intv_state>();
756741   switch (offset)
757742   {
758743      case 3:

Previous 199869 Revisions Next


© 1997-2024 The MAME Team