Previous 199869 Revisions Next

r33012 Monday 27th October, 2014 at 18:24:59 UTC by Osso
konamigx: Moved global variables into driver state (nw)
Let's see if I break line endings again.
[src/mame/drivers]konamigx.c mystwarr.c
[src/mame/includes]konamigx.h
[src/mame/machine]konamigx.c
[src/mame/video]konamigx.c

trunk/src/mame/drivers/konamigx.c
r241523r241524
106106
107107
108108
109
110static int konamigx_cfgport;
111
112static int gx_rdport1_3, gx_syncen;
113
114static emu_timer *dmadelay_timer;
115static emu_timer *boothack_timer;
116
117109/**********************************************************************************/
118110/*
119111   Konami ESC (E Security Chip) protection chip found on:
r241523r241524
179171
180172static void generate_sprites(address_space &space, UINT32 src, UINT32 spr, int count)
181173{
182   int i;
183   int scount;
184   int ecount;
185   scount = 0;
186   ecount = 0;
174   int scount = 0;
175   int ecount = 0;
187176
188   for(i=0; i<count; i++) {
177   for(int i=0; i<count; i++) {
189178      UINT32 adr = src + 0x100*i;
190179      int pri;
191180      if(!space.read_word(adr+2))
r241523r241524
200189   }
201190   //qsort(sprites, ecount, sizeof(struct sprite_entry), pri_comp);
202191
203   for(i=0; i<ecount; i++) {
192   for(int i=0; i<ecount; i++) {
204193      UINT32 adr = sprites[i].adr;
205194      if(adr) {
206195         UINT32 set =(space.read_word(adr) << 16)|space.read_word(adr+2);
r241523r241524
315304   }
316305}
317306
318static void tkmmpzdm_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
307void konamigx_state::tkmmpzdm_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
319308{
320   konamigx_state* state = space.machine().driver_data<konamigx_state>();
321   state->konamigx_esc_alert(space.machine().driver_data<konamigx_state>()->m_workram, 0x0142, 0x100, 0);
309   konamigx_esc_alert(m_workram, 0x0142, 0x100, 0);
322310}
323311
324static void dragoonj_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
312void konamigx_state::dragoonj_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
325313{
326   konamigx_state* state = space.machine().driver_data<konamigx_state>();
327   state->konamigx_esc_alert(space.machine().driver_data<konamigx_state>()->m_workram, 0x5c00, 0x100, 0);
314   konamigx_esc_alert(m_workram, 0x5c00, 0x100, 0);
328315}
329316
330static void sal2_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
317void konamigx_state::sal2_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
331318{
332   konamigx_state* state = space.machine().driver_data<konamigx_state>();
333   state->konamigx_esc_alert(space.machine().driver_data<konamigx_state>()->m_workram, 0x1c8c, 0x172, 1);
319   konamigx_esc_alert(m_workram, 0x1c8c, 0x172, 1);
334320}
335321
336static void sexyparo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
322void konamigx_state::sexyparo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
337323{
338324   // The d20000 should probably be p3
339325   generate_sprites(space, 0xc00604, 0xd20000, 0xfc);
340326}
341327
342static void tbyahhoo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
328void konamigx_state::tbyahhoo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
343329{
344330   generate_sprites(space, 0xc00000, 0xd20000, 0x100);
345331}
346332
347static void daiskiss_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
333void konamigx_state::daiskiss_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4)
348334{
349335   generate_sprites(space, 0xc00000, 0xd20000, 0x100);
350336}
351337
352static UINT8 esc_program[4096];
353static void (*esc_cb)(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
354
355338WRITE32_MEMBER(konamigx_state::esc_w)
356339{
357340   UINT32 opcode;
r241523r241524
386369         break;
387370      case 2: // Load program
388371         for(i=0; i<4096; i++)
389            esc_program[i] = space.read_byte(params+i);
372            m_esc_program[i] = space.read_byte(params+i);
390373/*
391374            {
392375                FILE *f;
r241523r241524
400383*/
401384         break;
402385      case 1: // Run program
403         if(esc_cb) {
386         if(m_esc_cb) {
404387            UINT32 p1 = (space.read_word(params+0)<<16) | space.read_word(params+2);
405388            UINT32 p2 = (space.read_word(params+4)<<16) | space.read_word(params+6);
406389            UINT32 p3 = (space.read_word(params+8)<<16) | space.read_word(params+10);
407390            UINT32 p4 = (space.read_word(params+12)<<16) | space.read_word(params+14);
408            esc_cb(space, p1, p2, p3, p4);
391            (this->*m_esc_cb)(space, p1, p2, p3, p4);
409392         }
410393         break;
411394      default:
r241523r241524
414397      }
415398      space.write_byte(data+9, ESTATE_END);
416399
417      if (konamigx_wrport1_1 & 0x10)
400      if (m_gx_wrport1_1 & 0x10)
418401      {
419         gx_rdport1_3 &= ~8;
402         m_gx_rdport1_3 &= ~8;
420403         m_maincpu->set_input_line(4, HOLD_LINE);
421404      }
422405   }
r241523r241524
439422
440423CUSTOM_INPUT_MEMBER(konamigx_state::gx_rdport1_3_r)
441424{
442   return (gx_rdport1_3 >> 1);
425   return (m_gx_rdport1_3 >> 1);
443426}
444427
445428WRITE32_MEMBER(konamigx_state::eeprom_w)
r241523r241524
462445
463446      m_eepromout->write(odata, 0xff);
464447
465      konamigx_wrport1_0 = odata;
448      m_gx_wrport1_0 = odata;
466449   }
467450
468451   if (ACCESSING_BITS_16_23)
r241523r241524
478461        bit 0 = CCU1-INT1 enable
479462      */
480463
481      konamigx_wrport1_1 = (data>>16)&0xff;
482//      logerror("write %x to IRQ register (PC=%x)\n", konamigx_wrport1_1, space.device().safe_pc());
464      m_gx_wrport1_1 = (data>>16)&0xff;
465//      logerror("write %x to IRQ register (PC=%x)\n", m_gx_wrport1_1, space.device().safe_pc());
483466
484      // gx_syncen is to ensure each IRQ is trigger at least once after being enabled
485      if (konamigx_wrport1_1 & 0x80)
486         gx_syncen |= konamigx_wrport1_1 & 0x1f;
467      // m_gx_syncen is to ensure each IRQ is triggered at least once after being enabled
468      if (m_gx_wrport1_1 & 0x80)
469         m_gx_syncen |= m_gx_wrport1_1 & 0x1f;
487470   }
488471}
489472
r241523r241524
526509
527510      m_k055673->k053246_set_objcha_line((data&0x100000) ? ASSERT_LINE : CLEAR_LINE);
528511
529      konamigx_wrport2 = (data>>16)&0xff;
512      m_gx_wrport2 = (data>>16)&0xff;
530513   }
531514}
532515
r241523r241524
534517/**********************************************************************************/
535518/* IRQ controllers */
536519
537static int suspension_active, resume_trigger;
538
539520READ32_MEMBER(konamigx_state::ccu_r)
540521{
541522   // the routine at 204abe in opengolf polls to see if we're in vblank (it wants values between 0x111 and 0x1df)
r241523r241524
559540      if (ACCESSING_BITS_24_31)
560541      {
561542         m_maincpu->set_input_line(1, CLEAR_LINE);
562         gx_syncen |= 0x20;
543         m_gx_syncen |= 0x20;
563544      }
564545
565546      // hblank interrupt ACK
566547      if (ACCESSING_BITS_8_15)
567548      {
568549         m_maincpu->set_input_line(2, CLEAR_LINE);
569         gx_syncen |= 0x40;
550         m_gx_syncen |= 0x40;
570551      }
571552   }
572553}
r241523r241524
588569TIMER_CALLBACK_MEMBER(konamigx_state::dmaend_callback)
589570{
590571   // foul-proof (CPU0 could be deactivated while we wait)
591   if (resume_trigger && suspension_active)
572   if (m_resume_trigger && m_suspension_active)
592573   {
593      suspension_active = 0;
594      machine().scheduler().trigger(resume_trigger);
574      m_suspension_active = 0;
575      machine().scheduler().trigger(m_resume_trigger);
595576   }
596577
597578   // DMA busy flag must be cleared before triggering IRQ 3
598   gx_rdport1_3 &= ~2;
579   m_gx_rdport1_3 &= ~2;
599580
600581   // IRQ 3 is the "object DMA end" IRQ also happens during vblank
601   if ((konamigx_wrport1_1 & 0x84) == 0x84 || (gx_syncen & 4))
582   if ((m_gx_wrport1_1 & 0x84) == 0x84 || (m_gx_syncen & 4))
602583   {
603      gx_syncen &= ~4;
584      m_gx_syncen &= ~4;
604585
605586      // lower OBJINT-REQ flag and trigger interrupt
606      gx_rdport1_3 &= ~0x80;
587      m_gx_rdport1_3 &= ~0x80;
607588      m_maincpu->set_input_line(3, HOLD_LINE);
608589   }
609590}
r241523r241524
611592void konamigx_state::dmastart_callback(int data)
612593{
613594   // raise the DMA busy flag
614   gx_rdport1_3 |= 2;
595   m_gx_rdport1_3 |= 2;
615596
616597   // begin transfer if DMAEN(bit4 of OBJSET1) is set (see p.48)
617598   if (m_k055673->k053246_read_register(5) & 0x10)
r241523r241524
621602   }
622603
623604   // simulate DMA delay
624   dmadelay_timer->adjust(attotime::from_usec(120));
605   m_dmadelay_timer->adjust(attotime::from_usec(120));
625606}
626607
627608
628609INTERRUPT_GEN_MEMBER(konamigx_state::konamigx_vbinterrupt)
629610{
630611   // lift idle suspension
631   if (resume_trigger && suspension_active)
612   if (m_resume_trigger && m_suspension_active)
632613   {
633      suspension_active = 0;
634      machine().scheduler().trigger(resume_trigger);
614      m_suspension_active = 0;
615      machine().scheduler().trigger(m_resume_trigger);
635616   }
636617
637618   // IRQ 1 is the main 60hz vblank interrupt
638   if (gx_syncen & 0x20)
619   if (m_gx_syncen & 0x20)
639620   {
640      gx_syncen &= ~0x20;
621      m_gx_syncen &= ~0x20;
641622
642      if ((konamigx_wrport1_1 & 0x81) == 0x81 || (gx_syncen & 1))
623      if ((m_gx_wrport1_1 & 0x81) == 0x81 || (m_gx_syncen & 1))
643624      {
644         gx_syncen &= ~1;
625         m_gx_syncen &= ~1;
645626         device.execute().set_input_line(1, HOLD_LINE);
646627      }
647628   }
r241523r241524
656637   if (scanline == 240)
657638   {
658639      // lift idle suspension
659      if (resume_trigger && suspension_active)
640      if (m_resume_trigger && m_suspension_active)
660641      {
661         suspension_active = 0;
662         machine().scheduler().trigger(resume_trigger);
642         m_suspension_active = 0;
643         machine().scheduler().trigger(m_resume_trigger);
663644      }
664645
665646      // IRQ 1 is the main 60hz vblank interrupt
666      // the gx_syncen & 0x20 test doesn't work on type 3 or 4 ROM boards, likely because the ROM board
647      // the m_gx_syncen & 0x20 test doesn't work on type 3 or 4 ROM boards, likely because the ROM board
667648      // generates the timing in those cases.  With this change, rushing heroes and rng2 boot :)
668649
669650      // maybe this interrupt should only be every 30fps, or maybe there are flags to prevent the game running too fast
670651      // the real hardware should output the display for each screen on alternate frames
671652      //  if(device->m_screen->frame_number() & 1)
672      if (1) // gx_syncen & 0x20)
653      if (1) // m_gx_syncen & 0x20)
673654      {
674         gx_syncen &= ~0x20;
655         m_gx_syncen &= ~0x20;
675656
676         if ((konamigx_wrport1_1 & 0x81) == 0x81 || (gx_syncen & 1))
657         if ((m_gx_wrport1_1 & 0x81) == 0x81 || (m_gx_syncen & 1))
677658         {
678            gx_syncen &= ~1;
659            m_gx_syncen &= ~1;
679660            m_maincpu->set_input_line(1, HOLD_LINE);
680661
681662         }
r241523r241524
686667   else if(scanline < 240) // hblank
687668   {
688669      // IRQ 2 is a programmable interrupt with scanline resolution
689      if (gx_syncen & 0x40)
670      if (m_gx_syncen & 0x40)
690671      {
691         gx_syncen &= ~0x40;
672         m_gx_syncen &= ~0x40;
692673
693         if ((konamigx_wrport1_1 & 0x82) == 0x82 || (gx_syncen & 2))
674         if ((m_gx_wrport1_1 & 0x82) == 0x82 || (m_gx_syncen & 2))
694675         {
695            gx_syncen &= ~2;
676            m_gx_syncen &= ~2;
696677            m_maincpu->set_input_line(2, HOLD_LINE);
697678         }
698679      }
r241523r241524
759740   return ROM[offset];
760741}
761742
762//static int sync_frame = 0;
763
764743READ32_MEMBER(konamigx_state::type3_sync_r)
765744{
766745   if(m_konamigx_current_frame==0)
r241523r241524
768747   else
769748      return 0;// return 0xfffffffe | 0;
770749}
771static int last_prot_op, last_prot_clk;
772750
751
773752/*
774753    Run and Gun 2, Rushing Heroes, Winning Spike, and Vs. Net Soccer contain a XILINX FPGA that serves as security.
775754
r241523r241524
844823    move.l  #$C10400,($C102EC).l       move.l  #$C10400,($C102EC).l
845824*/
846825
847//static int cc=0;
848
849826WRITE32_MEMBER(konamigx_state::type4_prot_w)
850827{
851828   int clk;
r241523r241524
853830
854831   if (offset == 1)
855832   {
856      last_prot_op = data>>16;
833      m_last_prot_op = data>>16;
857834   }
858835   else
859836   {
860837      data >>= 16;
861838
862839      clk = data & 0x200;
863      if ((clk == 0) && (last_prot_clk != 0))
840      if ((clk == 0) && (m_last_prot_clk != 0))
864841      {
865         if (last_prot_op != -1)
842         if (m_last_prot_op != -1)
866843         {
867//              osd_printf_debug("type 4 prot command: %x\n", last_prot_op);
844//              osd_printf_debug("type 4 prot command: %x\n", m_last_prot_op);
868845            /*
869846                known commands:
870847                rng2   rushhero  vsnet  winspike   what
r241523r241524
874851                       0d97  0515              parse big DMA list at c10200
875852                             57a       copy 4 bytes from c00f10 to c10f00 and 4 bytes from c00f30 to c0fe00
876853            */
877            if ((last_prot_op == 0xa56) || (last_prot_op == 0xd96) || (last_prot_op == 0xd14) || (last_prot_op == 0xd1c))
854            if ((m_last_prot_op == 0xa56) || (m_last_prot_op == 0xd96) || (m_last_prot_op == 0xd14) || (m_last_prot_op == 0xd1c))
878855            {
879856               // memcpy from c01000 to c01400 for 0x400 bytes (startup check for type 4 games)
880857               for (i = 0; i < 0x400; i += 2)
r241523r241524
882859                  space.write_word(0xc01400+i, space.read_word(0xc01000+i));
883860               }
884861            }
885            else if(last_prot_op == 0x57a)  // winspike
862            else if(m_last_prot_op == 0x57a)  // winspike
886863            {
887864               /* player 1 input buffer protection */
888865               space.write_dword(0xc10f00, space.read_dword(0xc00f10));
r241523r241524
894871               space.write_dword(0xc0fe00, space.read_dword(0xc00f30));
895872               space.write_dword(0xc0fe04, space.read_dword(0xc00f34));
896873            }
897            else if(last_prot_op == 0xd97)  // rushhero
874            else if(m_last_prot_op == 0xd97)  // rushhero
898875            {
899876               int src = 0xc09ff0;
900877               int dst = 0xd20000;
r241523r241524
917894               space.write_byte(0xc01cc4, ~space.read_byte(0xc00547));
918895               space.write_byte(0xc01cc5, ~space.read_byte(0xc00567));
919896            }
920            else if(last_prot_op == 0xb16) // slamdnk2
897            else if(m_last_prot_op == 0xb16) // slamdnk2
921898            {
922899               int src = 0xc01000;
923900               int dst = 0xd20000;
r241523r241524
932909
933910               //maybe here there's a [$d8001f] <- 0x31 write too?
934911            }
935            else if(last_prot_op == 0x515) // vsnetscr screen 1
912            else if(m_last_prot_op == 0x515) // vsnetscr screen 1
936913            {
937914               int adr;
938               //printf("GXT4: command %x %d (PC=%x)\n", last_prot_op, cc++, space.device().safe_pc());
915               //printf("GXT4: command %x %d (PC=%x)\n", m_last_prot_op, cc++, space.device().safe_pc());
939916               for (adr = 0; adr < 0x400; adr += 2)
940917                  space.write_word(0xc01c00+adr, space.read_word(0xc01800+adr));
941918            }
942            else if(last_prot_op == 0x115d) // vsnetscr screen 2
919            else if(m_last_prot_op == 0x115d) // vsnetscr screen 2
943920            {
944921               int adr;
945               //printf("GXT4: command %x %d (PC=%x)\n", last_prot_op, cc++, space.device().safe_pc());
922               //printf("GXT4: command %x %d (PC=%x)\n", m_last_prot_op, cc++, space.device().safe_pc());
946923               for (adr = 0; adr < 0x400; adr += 2)
947924                  space.write_word(0xc18c00+adr, space.read_word(0xc18800+adr));
948925            }
949926            else
950927            {
951               printf("GXT4: unknown protection command %x (PC=%x)\n", last_prot_op, space.device().safe_pc());
928               printf("GXT4: unknown protection command %x (PC=%x)\n", m_last_prot_op, space.device().safe_pc());
952929            }
953930
954            if (konamigx_wrport1_1 & 0x10)
931            if (m_gx_wrport1_1 & 0x10)
955932            {
956               gx_rdport1_3 &= ~8;
933               m_gx_rdport1_3 &= ~8;
957934               m_maincpu->set_input_line(4, HOLD_LINE);
958935            }
959936
960937            // don't accidentally do a phony command
961            last_prot_op = -1;
938            m_last_prot_op = -1;
962939         }
963940      }
964      last_prot_clk = clk;
941      m_last_prot_clk = clk;
965942   }
966943}
967944
r241523r241524
11801157
11811158   // note: racin' force expects bit 1 of the eeprom port to toggle
11821159   PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read)
1183   PORT_BIT( 0x000000fe, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, konamigx_state,gx_rdport1_3_r, NULL)
1160   PORT_BIT( 0x000000fe, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, konamigx_state, gx_rdport1_3_r, NULL)
11841161   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_COIN1 )
11851162   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_COIN2 )
11861163   PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN )
r241523r241524
35783555
35793556MACHINE_START_MEMBER(konamigx_state,konamigx)
35803557{
3581   save_item(NAME(konamigx_wrport1_1));
3558   save_item(NAME(m_gx_wrport1_1));
35823559}
35833560
35843561MACHINE_RESET_MEMBER(konamigx_state,konamigx)
35853562{
3586   konamigx_wrport1_0 = konamigx_wrport1_1 = 0;
3587   konamigx_wrport2 = 0;
3563   m_gx_wrport1_0 = m_gx_wrport1_1 = 0;
3564   m_gx_wrport2 = 0;
35883565
35893566/*
35903567    bit0  : EEPROM data(don't care)
35913568    bit1  : DMA busy   (cleared)
35923569    bit2-7: IRQ ready  (all set)
35933570*/
3594   gx_rdport1_3 = 0xfc;
3595   gx_syncen    = 0;
3596   suspension_active = 0;
3571   m_gx_rdport1_3 = 0xfc;
3572   m_gx_syncen    = 0;
3573   m_suspension_active = 0;
35973574
35983575   // Hold sound CPUs in reset
35993576   m_soundcpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
r241523r241524
36333610
36343611      // To hack around this, we underclock the 68020 for 10 seconds during POST
36353612      m_maincpu->set_clock_scale(0.66f);
3636      boothack_timer->adjust(attotime::from_seconds(10));
3613      m_boothack_timer->adjust(attotime::from_seconds(10));
36373614   }
36383615
36393616   if (!strcmp(setname, "le2") ||
r241523r241524
37083685   int i, match;
37093686   int readback = 0;
37103687
3711   konamigx_cfgport = -1;
3712   last_prot_op = -1;
3713   last_prot_clk = 0;
3688   m_gx_cfgport = -1;
3689   m_last_prot_op = -1;
3690   m_last_prot_clk = 0;
37143691
3715   esc_cb = 0;
3716   resume_trigger = 0;
3692   m_esc_cb = NULL;
3693   m_resume_trigger = 0;
37173694
3718   dmadelay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::dmaend_callback),this));
3719   boothack_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::boothack_callback),this));
3695   m_dmadelay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::dmaend_callback),this));
3696   m_boothack_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::boothack_callback),this));
37203697
37213698   i = match = 0;
37223699   while ((gameDefs[i].cfgport != -1) && (!match))
r241523r241524
37243701      if (!strcmp(machine().system().name, gameDefs[i].romname))
37253702      {
37263703         match = 1;
3727         konamigx_cfgport = gameDefs[i].cfgport;
3704         m_gx_cfgport = gameDefs[i].cfgport;
37283705         readback = gameDefs[i].readback;
37293706
37303707         switch (gameDefs[i].special)
r241523r241524
37453722               rom[0x810f1] &= ~1;      // fix checksum
37463723               rom[0x872ea] |= 0xe0000; // enable plane B,C,D
37473724
3748               esc_cb = tkmmpzdm_esc;
3725               m_esc_cb = &konamigx_state::tkmmpzdm_esc;
37493726               break;
37503727            }
37513728
37523729            case 3: // dragoon might
3753               esc_cb = dragoonj_esc;
3730               m_esc_cb = &konamigx_state::dragoonj_esc;
37543731               break;
37553732
37563733            case 4: // sexyparo
3757               esc_cb = sexyparo_esc;
3734               m_esc_cb = &konamigx_state::sexyparo_esc;
37583735               break;
37593736
37603737            case 5: // daiskiss
3761               esc_cb = daiskiss_esc;
3738               m_esc_cb = &konamigx_state::daiskiss_esc;
37623739               break;
37633740
37643741            case 6: // salamander 2
3765               esc_cb = sal2_esc;
3742               m_esc_cb = &konamigx_state::sal2_esc;
37663743               break;
37673744
37683745            case 7: // install type 4 Xilinx protection for non-type 3/4 games
r241523r241524
37703747               break;
37713748
37723749            case 8: // tbyahhoo
3773               esc_cb = tbyahhoo_esc;
3750               m_esc_cb = &konamigx_state::tbyahhoo_esc;
37743751               break;
37753752
37763753            case 9: // fantjour
trunk/src/mame/drivers/mystwarr.c
r241523r241524
847847   m_sound_ctrl = 2;
848848   reset_sound_region();
849849
850   m_mw_irq_control = 0;
851
852   /* konamigx_mixer uses this, so better initialize it */
853   konamigx_wrport1_0 = 0;
854
855   save_item(NAME(m_mw_irq_control));
856   save_item(NAME(m_sound_ctrl));
850   m_mw_irq_control = 0;
851 
852   /* konamigx_mixer uses this, so better initialize it */
853   m_gx_wrport1_0 = 0;
854 
855   save_item(NAME(m_mw_irq_control));
856   save_item(NAME(m_sound_ctrl));
857857   save_item(NAME(m_sound_nmi_clk));
858858
859859   machine().save().register_postload(save_prepost_delegate(FUNC(mystwarr_state::reset_sound_region), this));
trunk/src/mame/includes/konamigx.h
r241523r241524
1616      m_maincpu(*this,"maincpu"),
1717      m_soundcpu(*this, "soundcpu"),
1818      m_dasp(*this, "dasp"),
19      m_workram(*this,"workram"),
20      m_psacram(*this,"psacram"),
21      m_subpaletteram32(*this,"subpaletteram"),
2219      m_k055673(*this, "k055673"),
2320      m_k055555(*this, "k055555"),
2421      m_k056832(*this, "k056832"),
2522      m_k054338(*this, "k054338"),
23      m_k056800(*this, "k056800"),
24      m_k054539_1(*this,"k054539_1"),
25      m_k054539_2(*this,"k054539_2"),
26      m_gfxdecode(*this, "gfxdecode"),
27      m_screen(*this, "screen"),
28      m_palette(*this, "palette"),
29      m_workram(*this,"workram"),
30      m_psacram(*this,"psacram"),
31      m_subpaletteram32(*this,"subpaletteram"),
2632      m_k053936_0_ctrl(*this,"k053936_0_ctrl",32),
2733      m_k053936_0_linectrl(*this,"k053936_0_line",32),
2834      m_k053936_0_ctrl_16(*this,"k053936_0_ct16",16),
2935      m_k053936_0_linectrl_16(*this,"k053936_0_li16",16),
3036      m_konamigx_type3_psac2_bank(*this,"psac2_bank"),
31      m_k056800(*this, "k056800"),
32      m_k054539_1(*this,"k054539_1"),
33      m_k054539_2(*this,"k054539_2"),
37      m_generic_paletteram_32(*this, "paletteram"),
3438      m_an0(*this, "AN0"),
3539      m_an1(*this, "AN1"),
3640      m_light0_x(*this, "LIGHT0_X"),
3741      m_light0_y(*this, "LIGHT0_Y"),
3842      m_light1_x(*this, "LIGHT1_X"),
3943      m_light1_y(*this, "LIGHT1_Y"),
40      m_eepromout(*this, "EEPROMOUT"),
41      m_gfxdecode(*this, "gfxdecode"),
42      m_screen(*this, "screen"),
43      m_palette(*this, "palette"),
44      m_generic_paletteram_32(*this, "paletteram")
44      m_eepromout(*this, "EEPROMOUT")
4545      { }
4646
4747   required_device<cpu_device> m_maincpu;
4848   optional_device<cpu_device> m_soundcpu;
4949   optional_device<tms57002_device> m_dasp;
50
51   optional_shared_ptr<UINT32> m_workram;
52   optional_shared_ptr<UINT32> m_psacram;
53   optional_shared_ptr<UINT32> m_subpaletteram32;
5450   required_device<k055673_device> m_k055673;
5551   required_device<k055555_device> m_k055555;
5652   required_device<k056832_device> m_k056832;
5753   optional_device<k054338_device> m_k054338;
58   optional_shared_ptr<UINT16> m_k053936_0_ctrl;
59   optional_shared_ptr<UINT16> m_k053936_0_linectrl;
60   optional_shared_ptr<UINT16> m_k053936_0_ctrl_16;
61   optional_shared_ptr<UINT16> m_k053936_0_linectrl_16;
62   optional_shared_ptr<UINT32> m_konamigx_type3_psac2_bank;
6354   optional_device<k056800_device> m_k056800;
6455   optional_device<k054539_device> m_k054539_1;
6556   optional_device<k054539_device> m_k054539_2;
66   optional_ioport m_an0, m_an1, m_light0_x, m_light0_y, m_light1_x, m_light1_y, m_eepromout;
6757   required_device<gfxdecode_device> m_gfxdecode;
6858   required_device<screen_device> m_screen;
6959   required_device<palette_device> m_palette;
60
61   optional_shared_ptr<UINT32> m_workram;
62   optional_shared_ptr<UINT32> m_psacram;
63   optional_shared_ptr<UINT32> m_subpaletteram32;
64   optional_shared_ptr<UINT16> m_k053936_0_ctrl;
65   optional_shared_ptr<UINT16> m_k053936_0_linectrl;
66   optional_shared_ptr<UINT16> m_k053936_0_ctrl_16;
67   optional_shared_ptr<UINT16> m_k053936_0_linectrl_16;
68   optional_shared_ptr<UINT32> m_konamigx_type3_psac2_bank;
7069   optional_shared_ptr<UINT32> m_generic_paletteram_32;
70   
71   optional_ioport m_an0, m_an1, m_light0_x, m_light0_y, m_light1_x, m_light1_y, m_eepromout;
7172
7273   DECLARE_WRITE32_MEMBER(esc_w);
7374   DECLARE_WRITE32_MEMBER(eeprom_w);
r241523r241524
166167   void fantjour_dma_install();
167168
168169   void konamigx_mixer_primode(int mode);
170   
171   typedef void (konamigx_state::*esc_cb)(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
172   
173   void tkmmpzdm_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
174   void dragoonj_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
175   void sal2_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
176   void sexyparo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
177   void tbyahhoo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
178   void daiskiss_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4);
179   
180   inline int K053247GX_combine_c18(int attrib);
181   inline int K055555GX_decode_objcolor(int c18);
182   inline int K055555GX_decode_inpri(int c18);
183   int K055555GX_decode_vmixcolor(int layer, int *color);
169184
170185   UINT8 m_sound_ctrl;
171186   UINT8 m_sound_intck;
172187   UINT32 m_fantjour_dma[8];
173188   int m_konamigx_current_frame;
174189   int m_gx_objdma, m_gx_primode;
175};
190   emu_timer *m_dmadelay_timer;
191   emu_timer *m_boothack_timer;
192   int m_gx_rdport1_3, m_gx_syncen;
193   int m_gx_cfgport;
194   int m_suspension_active, m_resume_trigger;
195   int m_last_prot_op, m_last_prot_clk;
196     
197   UINT8 m_esc_program[4096];
198   esc_cb m_esc_cb;
199   
200   UINT16 m_prot_data[0x20];
201   
202   // 1st-Tier GX/MW Variables
203   // frequently used registers
204   int m_k053247_vrcbk[4];
205   int m_k053247_coreg, m_k053247_coregshift, m_k053247_opset;
206   int m_opri, m_oinprion;
207   int m_vcblk[6], m_ocblk;
208   int m_vinmix, m_vmixon, m_osinmix, m_osmixon;
209   UINT8  m_gx_wrport1_0, m_gx_wrport1_1;
210   UINT16 m_gx_wrport2;
211   
212   // 2nd-Tier GX/MW Graphics Variables
213   UINT8 *m_gx_objzbuf, *m_gx_shdzbuf;
214   int m_layer_colorbase[4];
215   INT32 m_gx_tilebanks[8], m_gx_oldbanks[8];
216   int m_gx_tilemode, m_gx_rozenable, m_psac_colorbase, m_last_psac_colorbase;
217   int m_gx_specialrozenable; // type 1 roz, with voxel height-map, rendered from 2 source tilemaps (which include height data) to temp bitmap for further processing
218   int m_gx_rushingheroes_hack;
219   int m_gx_le2_textcolour_hack;
220   tilemap_t *m_gx_psac_tilemap, *m_gx_psac_tilemap2;
221   bitmap_ind16 *m_type3_roz_temp_bitmap;
222   tilemap_t *m_gx_psac_tilemap_alt;
223   int m_konamigx_has_dual_screen;
224   int m_konamigx_palformat;
225   bitmap_rgb32 *m_dualscreen_left_tempbitmap;
226   bitmap_rgb32 *m_dualscreen_right_tempbitmap;
227   
228   /* On Type-1 the K053936 output is rendered to these temporary bitmaps as raw data
229    the 'voxel' effect to give the pixels height is a post-process operation on the
230    output of the K053936 (this can clearly be seen in videos as large chunks of
231    scenary flicker when in the distance due to single pixels in the K053936 output
232    becoming visible / invisible due to drawing precision.
176233
234    -- however, progress on this has stalled as our K053936 doesn't seem to give
235       the right output for post processing, I suspect the game is using some
236       unsupported flipping modes (probably due to the way it's hooked up to the
237       rest of the chips) which is causing entirely the wrong output.
177238
178/*----------- defined in video/konamigx.c -----------*/
239    -- furthermore video/konamigx.c contains it's own implementation of
240       the K053936_zoom_draw named K053936GP_zoom_draw ...
179241
180242
181// 1st-Tier GX/MW Variables and Functions
182extern UINT8  konamigx_wrport1_0, konamigx_wrport1_1;
183extern UINT16 konamigx_wrport2;
243    */
244   bitmap_ind16 *m_gxtype1_roz_dstbitmap;
245   bitmap_ind16 *m_gxtype1_roz_dstbitmap2;
246   rectangle m_gxtype1_roz_dstbitmapclip;
247};
184248
185
186
187249// Sprite Callbacks
188250
189251/* callbacks should return color codes in this format:
trunk/src/mame/machine/konamigx.c
r241523r241524
4141*/
4242
4343// K055550/K053990 protection chips, perform simple memset() and other game logic operations
44static UINT16 prot_data[0x20];
4544
4645
47
4846READ16_MEMBER(konamigx_state::K055550_word_r)
4947{
50   return(prot_data[offset]);
48   return(m_prot_data[offset]);
5149}
5250
5351WRITE16_MEMBER(konamigx_state::K055550_word_w)
r241523r241524
5654   int src, tgt, srcend, tgtend, skip, cx1, sx1, wx1, cy1, sy1, wy1, cz1, sz1, wz1, c2, s2, w2;
5755   int dx, dy, angle;
5856
59   COMBINE_DATA(prot_data+offset);
57   COMBINE_DATA(m_prot_data+offset);
6058
6159   if (offset == 0 && ACCESSING_BITS_8_15)
6260   {
r241523r241524
6563      {
6664         case 0x97: // memset() (Dadandarn at 0x639dc)
6765         case 0x9f: // memset() (Violent Storm at 0x989c)
68            adr   = (prot_data[7] << 16) | prot_data[8];
69            bsize = (prot_data[10] << 16) | prot_data[11];
70            count = (prot_data[0] & 0xff) + 1;
66            adr   = (m_prot_data[7] << 16) | m_prot_data[8];
67            bsize = (m_prot_data[10] << 16) | m_prot_data[11];
68            count = (m_prot_data[0] & 0xff) + 1;
7169
7270            lim = adr+bsize*count;
7371            for(i=adr; i<lim; i+=2)
74               space.write_word(i, prot_data[0x1a/2]);
72               space.write_word(i, m_prot_data[0x1a/2]);
7573         break;
7674
7775         // WARNING: The following cases are speculation based with questionable accuracy!(AAT)
r241523r241524
8280            // gameplay. It refers to a 32x8-word list at 0x210e00 and seems to
8381            // be tied with another 13x128-byte table at 0x205080.
8482            // Both tables appear "check-only" and have little effect on gameplay.
85            count =(prot_data[0] & 0xff) + 1;          // unknown ( byte 0x00)
86            i     = prot_data[1];                      // unknown ( byte 0x1f)
87            adr   = prot_data[7]<<16 | prot_data[8];   // address (dword 0x210e00)
88            lim   = prot_data[9];                      // unknown ( word 0x0010)
89            src   = prot_data[10]<<16 | prot_data[11]; // unknown (dword zero)
90            tgt   = prot_data[12]<<16 | prot_data[13]; // unknown (dword zero)
83            count =(m_prot_data[0] & 0xff) + 1;          // unknown ( byte 0x00)
84            i     = m_prot_data[1];                      // unknown ( byte 0x1f)
85            adr   = m_prot_data[7]<<16 | m_prot_data[8];   // address (dword 0x210e00)
86            lim   = m_prot_data[9];                      // unknown ( word 0x0010)
87            src   = m_prot_data[10]<<16 | m_prot_data[11]; // unknown (dword zero)
88            tgt   = m_prot_data[12]<<16 | m_prot_data[13]; // unknown (dword zero)
9189         break;
9290
9391         case 0xa0: // update collision detection table (Violent Storm at 0x018b42)
94            count = prot_data[0] & 0xff;             // number of objects - 1
95            skip  = prot_data[1]>>(8-1);             // words to skip in each entry to reach the "hit list"
96            adr   = prot_data[2]<<16 | prot_data[3]; // where the table is located
97            bsize = prot_data[5]<<16 | prot_data[6]; // object entry size in bytes
92            count = m_prot_data[0] & 0xff;             // number of objects - 1
93            skip  = m_prot_data[1]>>(8-1);             // words to skip in each entry to reach the "hit list"
94            adr   = m_prot_data[2]<<16 | m_prot_data[3]; // where the table is located
95            bsize = m_prot_data[5]<<16 | m_prot_data[6]; // object entry size in bytes
9896
9997            srcend = adr + bsize * count;
10098            tgtend = srcend + bsize;
r241523r241524
142140         break;
143141
144142         case 0xc0: // calculate object "homes-in" vector (Violent Storm at 0x03da9e)
145            dx = (short)prot_data[0xc];
146            dy = (short)prot_data[0xd];
143            dx = (short)m_prot_data[0xc];
144            dy = (short)m_prot_data[0xd];
147145
148146            // it's not necessary to use lookup tables because Violent Storm
149147            // only calls the service once per enemy per frame.
r241523r241524
165163            else
166164               i = machine().rand() & 0xff; // vector direction indeterminate
167165
168            prot_data[0x10] = i;
166            m_prot_data[0x10] = i;
169167         break;
170168
171169         default:
r241523r241524
183181   int mode, i, element_size = 1;
184182   UINT16 mod_val, mod_data;
185183
186   COMBINE_DATA(prot_data+offset);
184   COMBINE_DATA(m_prot_data+offset);
187185
188186   if (offset == 0x0c && ACCESSING_BITS_8_15)
189187   {
190      mode  = (prot_data[0x0d]<<8 & 0xff00) | (prot_data[0x0f] & 0xff);
188      mode  = (m_prot_data[0x0d]<<8 & 0xff00) | (m_prot_data[0x0f] & 0xff);
191189
192190      switch (mode)
193191      {
194192         case 0xffff: // word copy
195193            element_size = 2;
196194         case 0xff00: // byte copy
197            src_addr  = prot_data[0x0];
198            src_addr |= prot_data[0x1]<<16 & 0xff0000;
199            dst_addr  = prot_data[0x2];
200            dst_addr |= prot_data[0x3]<<16 & 0xff0000;
201            src_count = prot_data[0x8]>>8;
202            //dst_count = prot_data[0x9]>>8;
203            src_skip  = prot_data[0xa] & 0xff;
204            dst_skip  = prot_data[0xb] & 0xff;
195            src_addr  = m_prot_data[0x0];
196            src_addr |= m_prot_data[0x1]<<16 & 0xff0000;
197            dst_addr  = m_prot_data[0x2];
198            dst_addr |= m_prot_data[0x3]<<16 & 0xff0000;
199            src_count = m_prot_data[0x8]>>8;
200            //dst_count = m_prot_data[0x9]>>8;
201            src_skip  = m_prot_data[0xa] & 0xff;
202            dst_skip  = m_prot_data[0xb] & 0xff;
205203
206            if ((prot_data[0x8] & 0xff) == 2) src_count <<= 1;
204            if ((m_prot_data[0x8] & 0xff) == 2) src_count <<= 1;
207205            src_skip += element_size;
208206            dst_skip += element_size;
209207
r241523r241524
223221         break;
224222
225223         case 0x00ff: // sprite list modifier
226            src_addr  = prot_data[0x0];
227            src_addr |= prot_data[0x1]<<16 & 0xff0000;
228            src_skip  = prot_data[0x1]>>8;
229            dst_addr  = prot_data[0x2];
230            dst_addr |= prot_data[0x3]<<16 & 0xff0000;
231            dst_skip  = prot_data[0x3]>>8;
232            mod_addr  = prot_data[0x4];
233            mod_addr |= prot_data[0x5]<<16 & 0xff0000;
234            mod_skip  = prot_data[0x5]>>8;
235            mod_offs  = prot_data[0x8] & 0xff;
224            src_addr  = m_prot_data[0x0];
225            src_addr |= m_prot_data[0x1]<<16 & 0xff0000;
226            src_skip  = m_prot_data[0x1]>>8;
227            dst_addr  = m_prot_data[0x2];
228            dst_addr |= m_prot_data[0x3]<<16 & 0xff0000;
229            dst_skip  = m_prot_data[0x3]>>8;
230            mod_addr  = m_prot_data[0x4];
231            mod_addr |= m_prot_data[0x5]<<16 & 0xff0000;
232            mod_skip  = m_prot_data[0x5]>>8;
233            mod_offs  = m_prot_data[0x8] & 0xff;
236234            mod_offs<<= 1;
237235            mod_count = 0x100;
238236
trunk/src/mame/video/konamigx.c
r241523r241524
1111//#define GX_DEBUG
1212#define VERBOSE 0
1313
14/***************************************************************************/
15/*                                                                         */
16/*                     2nd-Tier GX/MW Graphics Functions                   */
17/*                                                                         */
18/***************************************************************************/
1914
20
21
22static UINT8 *gx_objzbuf, *gx_shdzbuf;
23
24
25
26static int layer_colorbase[4];
27static INT32 gx_tilebanks[8], gx_oldbanks[8];
28static int gx_tilemode, gx_rozenable, psac_colorbase, last_psac_colorbase;
29static int gx_specialrozenable; // type 1 roz, with voxel height-map, rendered from 2 source tilemaps (which include height data) to temp bitmap for further processing
30static int gx_rushingheroes_hack;
31static int gx_le2_textcolour_hack;
32static tilemap_t *gx_psac_tilemap, *gx_psac_tilemap2;
33static bitmap_ind16* type3_roz_temp_bitmap;
34static tilemap_t* gx_psac_tilemap_alt;
35
36static int konamigx_has_dual_screen;
3715INLINE void set_color_555(palette_device &palette, pen_t color, int rshift, int gshift, int bshift, UINT16 data);
38static int konamigx_palformat;
39static bitmap_rgb32* dualscreen_left_tempbitmap;
40static bitmap_rgb32* dualscreen_right_tempbitmap;
4116
42/* On Type-1 the K053936 output is rendered to these temporary bitmaps as raw data
43   the 'voxel' effect to give the pixels height is a post-process operation on the
44   output of the K053936 (this can clearly be seen in videos as large chunks of
45   scenary flicker when in the distance due to single pixels in the K053936 output
46   becoming visible / invisible due to drawing precision.
4717
48   -- however, progress on this has stalled as our K053936 doesn't seem to give
49      the right output for post processing, I suspect the game is using some
50      unsupported flipping modes (probably due to the way it's hooked up to the
51      rest of the chips) which is causing entirely the wrong output.
52
53   -- furthermore machine/konamigx.c (!) contains it's own implementation of
54      the K053936_zoom_draw named K053936GP_zoom_draw ... It really shouldn't do,
55      epsecially not in 'machine', which isn't meant to be video related.
56
57
58   */
59static bitmap_ind16 *gxtype1_roz_dstbitmap;
60static bitmap_ind16 *gxtype1_roz_dstbitmap2;
61static rectangle gxtype1_roz_dstbitmapclip;
62
63/***************************************************************************/
64/*                                                                         */
65/*                 1st-Tier GX/MW Variables and Functions                  */
66/*                                                                         */
67/***************************************************************************/
68
69// global system ports access
70UINT8  konamigx_wrport1_0, konamigx_wrport1_1;
71UINT16 konamigx_wrport2;
72
73// frequently used registers
74static int k053247_vrcbk[4];
75static int k053247_coreg, k053247_coregshift, k053247_opset;
76static int opri, oinprion;
77static int vcblk[6], ocblk;
78static int vinmix, vmixon, osinmix, osmixon;
79
80
8118void konamigx_state::konamigx_precache_registers(void)
8219{
8320   // (see sprite color coding scheme on p.46 & 47)
r241523r241524
8623   int i;
8724
8825   i = m_k055673->k053247_read_register(0x8/2);
89   k053247_vrcbk[0] = (i & 0x000f) << 14;
90   k053247_vrcbk[1] = (i & 0x0f00) << 6;
26   m_k053247_vrcbk[0] = (i & 0x000f) << 14;
27   m_k053247_vrcbk[1] = (i & 0x0f00) << 6;
9128   i = m_k055673->k053247_read_register(0xa/2);
92   k053247_vrcbk[2] = (i & 0x000f) << 14;
93   k053247_vrcbk[3] = (i & 0x0f00) << 6;
29   m_k053247_vrcbk[2] = (i & 0x000f) << 14;
30   m_k053247_vrcbk[3] = (i & 0x0f00) << 6;
9431
9532   // COREG == OBJSET2+1C == bit8-11 of OPSET ??? (see p.50 last table, needs p.49 to confirm)
96   k053247_opset = m_k055673->k053247_read_register(0xc/2);
33   m_k053247_opset = m_k055673->k053247_read_register(0xc/2);
9734
98   i = k053247_opset & 7; if (i > 4) i = 4;
35   i = m_k053247_opset & 7; if (i > 4) i = 4;
9936
100   k053247_coreg = m_k055673->k053247_read_register(0xc/2)>>8 & 0xf;
101   k053247_coreg =(k053247_coreg & coregmasks[i]) << 12;
37   m_k053247_coreg = m_k055673->k053247_read_register(0xc/2)>>8 & 0xf;
38   m_k053247_coreg =(m_k053247_coreg & coregmasks[i]) << 12;
10239
103   k053247_coregshift = coregshifts[i];
40   m_k053247_coregshift = coregshifts[i];
10441
105   opri     = m_k055555->K055555_read_register(K55_PRIINP_8);
106   oinprion = m_k055555->K055555_read_register(K55_OINPRI_ON);
107   vcblk[0] = m_k055555->K055555_read_register(K55_PALBASE_A);
108   vcblk[1] = m_k055555->K055555_read_register(K55_PALBASE_B);
109   vcblk[2] = m_k055555->K055555_read_register(K55_PALBASE_C);
110   vcblk[3] = m_k055555->K055555_read_register(K55_PALBASE_D);
111   vcblk[4] = m_k055555->K055555_read_register(K55_PALBASE_SUB1);
112   vcblk[5] = m_k055555->K055555_read_register(K55_PALBASE_SUB2);
113   ocblk    = m_k055555->K055555_read_register(K55_PALBASE_OBJ);
114   vinmix   = m_k055555->K055555_read_register(K55_BLEND_ENABLES);
115   vmixon   = m_k055555->K055555_read_register(K55_VINMIX_ON);
116   osinmix  = m_k055555->K055555_read_register(K55_OSBLEND_ENABLES);
117   osmixon  = m_k055555->K055555_read_register(K55_OSBLEND_ON);
42   m_opri     = m_k055555->K055555_read_register(K55_PRIINP_8);
43   m_oinprion = m_k055555->K055555_read_register(K55_OINPRI_ON);
44   m_vcblk[0] = m_k055555->K055555_read_register(K55_PALBASE_A);
45   m_vcblk[1] = m_k055555->K055555_read_register(K55_PALBASE_B);
46   m_vcblk[2] = m_k055555->K055555_read_register(K55_PALBASE_C);
47   m_vcblk[3] = m_k055555->K055555_read_register(K55_PALBASE_D);
48   m_vcblk[4] = m_k055555->K055555_read_register(K55_PALBASE_SUB1);
49   m_vcblk[5] = m_k055555->K055555_read_register(K55_PALBASE_SUB2);
50   m_ocblk    = m_k055555->K055555_read_register(K55_PALBASE_OBJ);
51   m_vinmix   = m_k055555->K055555_read_register(K55_BLEND_ENABLES);
52   m_vmixon   = m_k055555->K055555_read_register(K55_VINMIX_ON);
53   m_osinmix  = m_k055555->K055555_read_register(K55_OSBLEND_ENABLES);
54   m_osmixon  = m_k055555->K055555_read_register(K55_OSBLEND_ON);
11855}
11956
120INLINE int K053247GX_combine_c18(int attrib) // (see p.46)
57inline int konamigx_state::K053247GX_combine_c18(int attrib) // (see p.46)
12158{
12259   int c18;
12360
124   c18 = (attrib & 0xff)<<k053247_coregshift | k053247_coreg;
61   c18 = (attrib & 0xff)<<m_k053247_coregshift | m_k053247_coreg;
12562
126   if (konamigx_wrport2 & 4) c18 &= 0x3fff; else
127   if (!(konamigx_wrport2 & 8)) c18 = (c18 & 0x3fff) | (attrib<<6 & 0xc000);
63   if (m_gx_wrport2 & 4) c18 &= 0x3fff; else
64   if (!(m_gx_wrport2 & 8)) c18 = (c18 & 0x3fff) | (attrib<<6 & 0xc000);
12865
12966   return(c18);
13067}
13168
132INLINE int K055555GX_decode_objcolor(int c18) // (see p.59 7.2.2)
69inline int konamigx_state::K055555GX_decode_objcolor(int c18) // (see p.59 7.2.2)
13370{
13471   int ocb, opon;
13572
136   opon  = oinprion<<8 | 0xff;
137   ocb   = (ocblk & 7) << 10;
73   opon  = m_oinprion<<8 | 0xff;
74   ocb   = (m_ocblk & 7) << 10;
13875   c18  &= opon;
13976   ocb  &=~opon;
14077
141   return((ocb | c18) >> k053247_coregshift);
78   return((ocb | c18) >> m_k053247_coregshift);
14279}
14380
144INLINE int K055555GX_decode_inpri(int c18) // (see p.59 7.2.2)
81inline int konamigx_state::K055555GX_decode_inpri(int c18) // (see p.59 7.2.2)
14582{
146   int op = opri;
83   int op = m_opri;
14784
14885   c18 >>= 8;
149   op   &= oinprion;
150   c18  &=~oinprion;
86   op   &= m_oinprion;
87   c18  &=~m_oinprion;
15188
15289   return(c18 | op);
15390}
r241523r241524
15794   int num = *code;
15895   int c18 = *color;
15996
160   *code = k053247_vrcbk[num>>14] | (num & 0x3fff);
97   *code = m_k053247_vrcbk[num>>14] | (num & 0x3fff);
16198   c18 = K053247GX_combine_c18(c18);
16299   *color = K055555GX_decode_objcolor(c18);
163100   *priority_mask = K055555GX_decode_inpri(c18);
r241523r241524
168105   int num, op, pri, c18;
169106
170107   num = *code;
171   *code = k053247_vrcbk[num>>14] | (num & 0x3fff);
108   *code = m_k053247_vrcbk[num>>14] | (num & 0x3fff);
172109
173110   c18  = pri = *color;
174   op   = opri;
111   op   = m_opri;
175112   pri  = (pri & 0x200) ? 4 : pri>>4 & 0xf;
176   op  &= oinprion;
177   pri &=~oinprion;
113   op  &= m_oinprion;
114   pri &=~m_oinprion;
178115   *priority_mask = pri | op;
179116
180117   c18 = K053247GX_combine_c18(c18);
r241523r241524
186123   int num, op, pri, c18;
187124
188125   num = *code;
189   *code = k053247_vrcbk[num>>14] | (num & 0x3fff);
126   *code = m_k053247_vrcbk[num>>14] | (num & 0x3fff);
190127
191128   c18  = pri = *color;
192   op   = opri;
129   op   = m_opri;
193130   pri  = pri>>4 & 0x3f;
194   op  &= oinprion;
195   pri &=~oinprion;
131   op  &= m_oinprion;
132   pri &=~m_oinprion;
196133   *priority_mask = pri | op;
197134
198135   c18 = K053247GX_combine_c18(c18);
r241523r241524
204141   int num, op, pri;
205142
206143   num = *code;
207   *code = k053247_vrcbk[num>>14] | (num & 0x3fff);
144   *code = m_k053247_vrcbk[num>>14] | (num & 0x3fff);
208145
209146   pri = *color;
210147   *color &= 0x1f;
211148
212   op   = opri;
149   op   = m_opri;
213150   pri &= 0xf0;
214   op  &= oinprion;
215   pri &=~oinprion;
151   op  &= m_oinprion;
152   pri &=~m_oinprion;
216153   *priority_mask = pri | op;
217154}
218155
219static int K055555GX_decode_vmixcolor(int layer, int *color) // (see p.62 7.2.6 and p.27 3.3)
156int konamigx_state::K055555GX_decode_vmixcolor(int layer, int *color) // (see p.62 7.2.6 and p.27 3.3)
220157{
221158   int vcb, shift, pal, vmx, von, pl45, emx;
222159
223   vcb    =  vcblk[layer]<<6;
160   vcb    =  m_vcblk[layer]<<6;
224161   shift  =  layer<<1;
225162   pal    =  *color;
226   vmx    =  vinmix>>shift & 3;
227   von    =  vmixon>>shift & 3;
163   vmx    =  m_vinmix>>shift & 3;
164   von    =  m_vmixon>>shift & 3;
228165   emx    =  pl45 = pal>>4 & 3;
229166   pal   &=  0xf;
230167   pl45  &=  von;
r241523r241524
235172   emx   |=  vmx;
236173   pal   |=  vcb;
237174
238   if (gx_le2_textcolour_hack)
175   if (m_gx_le2_textcolour_hack)
239176      if (layer==0)
240177         pal |= 0x1c0;
241178
r241523r241524
252189
253190   shift  =  layer<<1;
254191   pal    =  *color;
255   osmx   =  osinmix>>shift & 3;
256   oson   =  osmixon>>shift & 3;
192   osmx   =  m_osinmix>>shift & 3;
193   oson   =  m_osmixon>>shift & 3;
257194
258195   if (layer)
259196   {
260197      // layer 1-3 are external tile layers
261      scb    =  vcblk[layer+3]<<6;
198      scb    =  m_vcblk[layer+3]<<6;
262199      emx    =  pl45 = pal>>4 & 3;
263200      pal   &=  0xf;
264201      pl45  &=  oson;
r241523r241524
292229   int w = visarea.width();
293230   int h = visarea.height();
294231
295   UINT8 *zptr = gx_objzbuf;
232   UINT8 *zptr = m_gx_objzbuf;
296233   int ecx = h;
297234
298235   do { memset(zptr, -1, w); zptr += GX_ZBUFW; } while (--ecx);
299236
300237   if (!noshadow)
301238   {
302      zptr = gx_shdzbuf;
239      zptr = m_gx_shdzbuf;
303240      w <<= 1;
304241      ecx = h;
305242      do { memset(zptr, -1, w); zptr += (GX_ZBUFW<<1); } while (--ecx);
r241523r241524
350287   m_gx_objdma = 0;
351288   m_gx_primode = 0;
352289
353   gx_objzbuf = &screen.priority().pix8(0);
354   gx_shdzbuf = auto_alloc_array(machine(), UINT8, GX_ZBUFSIZE);
290   m_gx_objzbuf = &screen.priority().pix8(0);
291   m_gx_shdzbuf = auto_alloc_array(machine(), UINT8, GX_ZBUFSIZE);
355292   gx_objpool = auto_alloc_array(machine(), struct GX_OBJ, GX_MAX_OBJECTS);
356293
357294   m_k054338->export_config(&K054338_shdRGB);
r241523r241524
393330   int cltc_shdpri, /*prflp,*/ disp;
394331
395332   // buffer can move when it's resized, so refresh the pointer
396   gx_objzbuf = &screen.priority().pix8(0);
333   m_gx_objzbuf = &screen.priority().pix8(0);
397334
398335   // abort if object database failed to initialize
399336   objpool = gx_objpool;
400337   if (!objpool) return;
401338
402339   // clear screen with backcolor and update flicker pulse
403   if (konamigx_wrport1_0 & 0x20)
340   if (m_gx_wrport1_0 & 0x20)
404341      m_k054338->fill_backcolor(bitmap,
405342                           cliprect,
406343                           m_palette->pens() + (m_k055555->K055555_read_register(0) << 9),
r241523r241524
564501      int zcode = gx_spriteram[offs] & 0xff;
565502
566503      // invert z-order when opset_pri is set (see p.51 OPSET PRI)
567      if (k053247_opset & 0x10) zcode = 0xff - zcode;
504      if (m_k053247_opset & 0x10) zcode = 0xff - zcode;
568505
569506      int code  = gx_spriteram[offs+1];
570507      int color = k = gx_spriteram[offs+6];
r241523r241524
635572         if (temp3)
636573         {
637574            // determine shadow priority
638            spri = (k053247_opset & 0x20) ? pri : shdpri[shadow]; // (see p.51 OPSET SDSEL)
575            spri = (m_k053247_opset & 0x20) ? pri : shdpri[shadow]; // (see p.51 OPSET SDSEL)
639576         }
640577      }
641578
r241523r241524
732669      if (j == GXMIX_BLEND_FORCE) { temp1 = 0x00; temp2 = mixerflags>>(i+16); temp3 = 3; }
733670      else
734671      {
735         temp1 = vinmix;
736         temp2 = vinmix>>i & 3;
737         temp3 = vmixon>>i & 3;
672         temp1 = m_vinmix;
673         temp2 = m_vinmix>>i & 3;
674         temp3 = m_vmixon>>i & 3;
738675      }
739676
740677      /* blend layer only when:
741          1) vinmix != 0xff
678          1) m_vinmix != 0xff
742679          2) its internal mix code is set
743680          3) all mix code bits are internal(overriden until tile blending has been implemented)
744681          4) 0 > alpha < 255;
r241523r241524
775712      if (j == GXMIX_BLEND_FORCE) { temp1 = 0x00; temp2 = mixerflags>>24; temp3 = 3; }
776713      else
777714      {
778         temp1 = osinmix;
779         temp2 = osinmix>>2 & 3;
780         temp3 = osmixon>>2 & 3;
715         temp1 = m_osinmix;
716         temp2 = m_osinmix>>2 & 3;
717         temp3 = m_osmixon>>2 & 3;
781718      }
782719
783720      if (temp1!=0xff && temp2 /*&& temp3==3*/)
r241523r241524
803740      }
804741      else
805742      {
806         machine().device<k053250_device>("k053250_1")->draw(bitmap, cliprect, vcblk[4]<<l, 0, screen.priority(), 0);
743         machine().device<k053250_device>("k053250_1")->draw(bitmap, cliprect, m_vcblk[4]<<l, 0, screen.priority(), 0);
807744      }
808745   }
809746}
r241523r241524
825762      if (j == GXMIX_BLEND_FORCE) { temp1 = 0x00; temp2 = mixerflags>>26; temp3 = 3; }
826763      else
827764      {
828         temp1 = osinmix;
829         temp2 = osinmix>>4 & 3;
830         temp3 = osmixon>>4 & 3;
765         temp1 = m_osinmix;
766         temp2 = m_osinmix>>4 & 3;
767         temp3 = m_osmixon>>4 & 3;
831768      }
832769
833770      if (temp1!=0xff && temp2 /*&& temp3==3*/)
r241523r241524
875812         }
876813      }
877814      else
878         machine().device<k053250_device>("k053250_2")->draw(bitmap, cliprect, vcblk[5]<<l, 0, screen.priority(), 0);
815         machine().device<k053250_device>("k053250_2")->draw(bitmap, cliprect, m_vcblk[5]<<l, 0, screen.priority(), 0);
879816   }
880817}
881818
r241523r241524
932869
933870
934871         m_k055673->k053247_draw_single_sprite_gxcore(bitmap, cliprect,
935            gx_objzbuf, gx_shdzbuf, code, gx_spriteram, offs,
872            m_gx_objzbuf, m_gx_shdzbuf, code, gx_spriteram, offs,
936873            color, alpha, drawmode, zcode, pri,
937874            /* non-gx only */
938875            0,0,NULL,NULL,0
r241523r241524
985922
986923   }
987924
988   colour = (psac_colorbase << 4) + col;
925   colour = (m_psac_colorbase << 4) + col;
989926
990927   SET_TILE_INFO_MEMBER(0, tileno, colour, TILE_FLIPYX(flip));
991928}
r241523r241524
1003940   /* handle this by creating 2 roz tilemaps instead, otherwise performance dies completely on dual screen mode
1004941   if (konamigx_type3_psac2_actual_bank!=konamigx_type3_psac2_actual_last_bank)
1005942   {
1006       gx_psac_tilemap->mark_all_dirty();
943       m_gx_psac_tilemap->mark_all_dirty();
1007944       konamigx_type3_psac2_actual_last_bank = konamigx_type3_psac2_actual_bank;
1008945   }
1009946   */
r241523r241524
11061043{
11071044   int d = *code;
11081045
1109   *code = (gx_tilebanks[(d & 0xe000)>>13]<<13) + (d & 0x1fff);
1046   *code = (m_gx_tilebanks[(d & 0xe000)>>13]<<13) + (d & 0x1fff);
11101047   K055555GX_decode_vmixcolor(layer, color);
11111048}
11121049
r241523r241524
11181055   mixcode = K055555GX_decode_vmixcolor(layer, color);
11191056
11201057   if (mixcode < 0)
1121      *code = (gx_tilebanks[(d & 0xe000)>>13]<<13) + (d & 0x1fff);
1058      *code = (m_gx_tilebanks[(d & 0xe000)>>13]<<13) + (d & 0x1fff);
11221059   else
11231060   {
11241061      /* save mixcode and mark tile alpha (unimplemented) */
r241523r241524
11651102
11661103   for (int i = 0; i < 8; i++)
11671104   {
1168      gx_tilebanks[i] = gx_oldbanks[i] = 0;
1105      m_gx_tilebanks[i] = m_gx_oldbanks[i] = 0;
11691106   }
11701107
1171   machine().save().save_item(NAME(gx_tilebanks));
1108   machine().save().save_item(NAME(m_gx_tilebanks));
11721109
1173   gx_tilemode = 0;
1110   m_gx_tilemode = 0;
11741111
1175   gx_rozenable = 0;
1176   gx_specialrozenable = 0;
1177   gx_rushingheroes_hack = 0;
1178   gx_le2_textcolour_hack = 0;
1112   m_gx_rozenable = 0;
1113   m_gx_specialrozenable = 0;
1114   m_gx_rushingheroes_hack = 0;
1115   m_gx_le2_textcolour_hack = 0;
11791116
11801117   // Documented relative offsets of non-flipped games are (-2, 0, 2, 3),(0, 0, 0, 0).
11811118   // (+ve values move layers to the right and -ve values move layers to the left)
r241523r241524
11871124   m_k056832->set_layer_offs(2,  2, 0);
11881125   m_k056832->set_layer_offs(3,  3, 0);
11891126
1190   konamigx_has_dual_screen = 0;
1127   m_konamigx_has_dual_screen = 0;
11911128   m_konamigx_current_frame = 0;
11921129}
11931130
r241523r241524
11971134   common_init();
11981135
11991136   if (!strcmp(machine().system().name,"tbyahhoo"))
1200      gx_tilemode = 1;
1137      m_gx_tilemode = 1;
12011138   else if (!strcmp(machine().system().name,"crzcross") || !strcmp(machine().system().name,"puzldama"))
12021139      konamigx_mixer_primode(5);
12031140   else if (!strcmp(machine().system().name,"daiskiss"))
r241523r241524
12201157
12211158   konamigx_mixer_primode(-1); // swapped layer B and C priorities?
12221159
1223   gx_le2_textcolour_hack = 1; // force text layer to use the right palette
1160   m_gx_le2_textcolour_hack = 1; // force text layer to use the right palette
12241161}
12251162
12261163VIDEO_START_MEMBER(konamigx_state, konamigx_6bpp)
r241523r241524
12341171   int width = m_screen->width();
12351172   int height = m_screen->height();
12361173
1237   dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1238   dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1174   m_dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1175   m_dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
12391176
12401177   common_init();
12411178
1242   gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac3_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 256, 256);
1243   gx_psac_tilemap_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac3_alt_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 256, 256);
1179   m_gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac3_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 256, 256);
1180   m_gx_psac_tilemap_alt = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac3_alt_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 256, 256);
12441181
1245   gx_rozenable = 0;
1246   gx_specialrozenable = 2;
1182   m_gx_rozenable = 0;
1183   m_gx_specialrozenable = 2;
12471184
12481185
12491186   /* set up tile layers */
1250   type3_roz_temp_bitmap = auto_bitmap_ind16_alloc(machine(), width, height);
1187   m_type3_roz_temp_bitmap = auto_bitmap_ind16_alloc(machine(), width, height);
12511188
12521189
1253   //gx_psac_tilemap->set_flip(TILEMAP_FLIPX| TILEMAP_FLIPY);
1190   //m_gx_psac_tilemap->set_flip(TILEMAP_FLIPX| TILEMAP_FLIPY);
12541191
12551192   K053936_wraparound_enable(0, 1);
12561193//  K053936GP_set_offset(0, -30, -1);
r241523r241524
12611198   m_k056832->set_layer_offs(2,  -48, 0);
12621199   m_k056832->set_layer_offs(3,  -48, 0);
12631200
1264   konamigx_has_dual_screen = 1;
1265   konamigx_palformat = 1;
1201   m_konamigx_has_dual_screen = 1;
1202   m_konamigx_palformat = 1;
12661203}
12671204
12681205VIDEO_START_MEMBER(konamigx_state, konamigx_type4)
r241523r241524
12701207   int width = m_screen->width();
12711208   int height = m_screen->height();
12721209
1273   dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1274   dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1210   m_dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1211   m_dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
12751212
12761213   common_init();
12771214
1278   gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1279   gx_rozenable = 0;
1280   gx_specialrozenable = 3;
1215   m_gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1216   m_gx_rozenable = 0;
1217   m_gx_specialrozenable = 3;
12811218
12821219   m_k056832->set_layer_offs(0,  -27, 0);
12831220   m_k056832->set_layer_offs(1,  -25, 0);
r241523r241524
12871224   K053936_wraparound_enable(0, 0);
12881225   K053936GP_set_offset(0, -36, 1);
12891226
1290   gx_rushingheroes_hack = 1;
1291   konamigx_has_dual_screen = 1;
1292   konamigx_palformat = 0;
1227   m_gx_rushingheroes_hack = 1;
1228   m_konamigx_has_dual_screen = 1;
1229   m_konamigx_palformat = 0;
12931230
12941231}
12951232
r241523r241524
12981235   int width = m_screen->width();
12991236   int height = m_screen->height();
13001237
1301   dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1302   dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1238   m_dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1239   m_dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
13031240
13041241   common_init();
13051242
1306   gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1307   gx_rozenable = 0;
1308   gx_specialrozenable = 3;
1243   m_gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1244   m_gx_rozenable = 0;
1245   m_gx_specialrozenable = 3;
13091246
13101247   m_k056832->set_layer_offs(0,  -52, 0);
13111248   m_k056832->set_layer_offs(1,  -48, 0);
r241523r241524
13151252   K053936_wraparound_enable(0, 1); // wraparound doesn't work properly with the custom drawing function anyway, see the crowd in vsnet and rushhero
13161253   K053936GP_set_offset(0, -30, 0);
13171254
1318   gx_rushingheroes_hack = 1;
1319   konamigx_has_dual_screen = 1;
1320   konamigx_palformat = 0;
1255   m_gx_rushingheroes_hack = 1;
1256   m_konamigx_has_dual_screen = 1;
1257   m_konamigx_palformat = 0;
13211258}
13221259
13231260VIDEO_START_MEMBER(konamigx_state, konamigx_type4_sd2)
r241523r241524
13251262   int width = m_screen->width();
13261263   int height = m_screen->height();
13271264
1328   dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1329   dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1265   m_dualscreen_left_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
1266   m_dualscreen_right_tempbitmap = auto_bitmap_rgb32_alloc(machine(), width, height);
13301267
13311268   common_init();
13321269
1333   gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1334   gx_rozenable = 0;
1335   gx_specialrozenable = 3;
1270   m_gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1271   m_gx_rozenable = 0;
1272   m_gx_specialrozenable = 3;
13361273
13371274
13381275   m_k056832->set_layer_offs(0,  -29, -1);
r241523r241524
13441281   K053936_wraparound_enable(0, 0);
13451282   K053936GP_set_offset(0, -36, -1);
13461283
1347   gx_rushingheroes_hack = 1;
1348   konamigx_has_dual_screen = 1;
1349   konamigx_palformat = 0;
1284   m_gx_rushingheroes_hack = 1;
1285   m_konamigx_has_dual_screen = 1;
1286   m_konamigx_palformat = 0;
13501287
13511288}
13521289
r241523r241524
13591296   m_k056832->set_layer_offs(2,  2+1, 0);
13601297   m_k056832->set_layer_offs(3,  3+1, 0);
13611298
1362   gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1a_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1363   gx_psac_tilemap2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1b_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1299   m_gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1a_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1300   m_gx_psac_tilemap2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1b_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
13641301
13651302   // transparency will be handled manually in post-processing
1366   //gx_psac_tilemap->set_transparent_pen(0);
1367   //gx_psac_tilemap2->set_transparent_pen(0);
1303   //m_gx_psac_tilemap->set_transparent_pen(0);
1304   //m_gx_psac_tilemap2->set_transparent_pen(0);
13681305
1369   gx_rozenable = 0;
1370   gx_specialrozenable = 1;
1306   m_gx_rozenable = 0;
1307   m_gx_specialrozenable = 1;
13711308
1372   gxtype1_roz_dstbitmap =  auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
1373   gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
1309   m_gxtype1_roz_dstbitmap =  auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
1310   m_gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
13741311
13751312
1376   gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1);
1313   m_gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1);
13771314
13781315
13791316   K053936_wraparound_enable(0, 1);
r241523r241524
13941331   m_k056832->set_layer_offs(2,  2+1, 0);
13951332   m_k056832->set_layer_offs(3,  3+1, 0);
13961333
1397   gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1a_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1398   gx_psac_tilemap2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1b_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1334   m_gx_psac_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1a_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
1335   m_gx_psac_tilemap2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(konamigx_state::get_gx_psac1b_tile_info),this), TILEMAP_SCAN_COLS,  16, 16, 128, 128);
13991336
14001337   // transparency will be handled manually in post-processing
1401   //gx_psac_tilemap->set_transparent_pen(0);
1402   //gx_psac_tilemap2->set_transparent_pen(0);
1338   //m_gx_psac_tilemap->set_transparent_pen(0);
1339   //m_gx_psac_tilemap2->set_transparent_pen(0);
14031340
1404   gx_rozenable = 0;
1405   gx_specialrozenable = 1;
1341   m_gx_rozenable = 0;
1342   m_gx_specialrozenable = 1;
14061343
1407   gxtype1_roz_dstbitmap =  auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
1408   gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
1344   m_gxtype1_roz_dstbitmap =  auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
1345   m_gxtype1_roz_dstbitmap2 = auto_bitmap_ind16_alloc(machine(),512,512); // BITMAP_FORMAT_IND16 because we NEED the raw pen data for post-processing
14091346
14101347
1411   gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1);
1348   m_gxtype1_roz_dstbitmapclip.set(0, 512-1, 0, 512-1);
14121349
14131350
14141351   K053936_wraparound_enable(0, 1);
r241523r241524
14281365   /* if any banks are different from last render, we need to flush the planes */
14291366   for (dirty = 0, i = 0; i < 8; i++)
14301367   {
1431      newbank = gx_tilebanks[i];
1432      if (gx_oldbanks[i] != newbank) { gx_oldbanks[i] = newbank; dirty = 1; }
1368      newbank = m_gx_tilebanks[i];
1369      if (m_gx_oldbanks[i] != newbank) { m_gx_oldbanks[i] = newbank; dirty = 1; }
14331370   }
14341371
1435   if (gx_tilemode == 0)
1372   if (m_gx_tilemode == 0)
14361373   {
14371374      // driver approximates tile update in mode 0 for speed
14381375      unchained = m_k056832->get_layer_association();
14391376      for (i=0; i<4; i++)
14401377      {
14411378         newbase = m_k055555->K055555_get_palette_index(i)<<6;
1442         if (layer_colorbase[i] != newbase)
1379         if (m_layer_colorbase[i] != newbase)
14431380         {
1444            layer_colorbase[i] = newbase;
1381            m_layer_colorbase[i] = newbase;
14451382
14461383            if (unchained)
14471384               m_k056832->mark_plane_dirty(i);
r241523r241524
14561393   }
14571394
14581395   // sub2 is PSAC colorbase on GX
1459   if (gx_rozenable)
1396   if (m_gx_rozenable)
14601397   {
1461      last_psac_colorbase = psac_colorbase;
1462      psac_colorbase = m_k055555->K055555_get_palette_index(6);
1398      m_last_psac_colorbase = m_psac_colorbase;
1399      m_psac_colorbase = m_k055555->K055555_get_palette_index(6);
14631400
1464      if (psac_colorbase != last_psac_colorbase)
1401      if (m_psac_colorbase != m_last_psac_colorbase)
14651402      {
1466         gx_psac_tilemap->mark_all_dirty();
1467         if (gx_rozenable == 3)
1403         m_gx_psac_tilemap->mark_all_dirty();
1404         if (m_gx_rozenable == 3)
14681405         {
1469            gx_psac_tilemap2->mark_all_dirty();
1406            m_gx_psac_tilemap2->mark_all_dirty();
14701407         }
14711408      }
14721409   }
r241523r241524
14741411   if (dirty) m_k056832->mark_all_tilemaps_dirty();
14751412
14761413   // Type-1
1477   if (gx_specialrozenable == 1)
1414   if (m_gx_specialrozenable == 1)
14781415   {
1479      K053936_0_zoom_draw(screen, *gxtype1_roz_dstbitmap, gxtype1_roz_dstbitmapclip,gx_psac_tilemap, 0,0,0); // height data
1480      K053936_0_zoom_draw(screen, *gxtype1_roz_dstbitmap2,gxtype1_roz_dstbitmapclip,gx_psac_tilemap2,0,0,0); // colour data (+ some voxel height data?)
1416      K053936_0_zoom_draw(screen, *m_gxtype1_roz_dstbitmap, m_gxtype1_roz_dstbitmapclip,m_gx_psac_tilemap, 0,0,0); // height data
1417      K053936_0_zoom_draw(screen, *m_gxtype1_roz_dstbitmap2,m_gxtype1_roz_dstbitmapclip,m_gx_psac_tilemap2,0,0,0); // colour data (+ some voxel height data?)
14811418   }
14821419
14831420
14841421
1485   if (gx_specialrozenable==3)
1422   if (m_gx_specialrozenable==3)
14861423   {
1487      konamigx_mixer(screen, bitmap, cliprect, gx_psac_tilemap, GXSUB_8BPP,0,0,  0, 0, gx_rushingheroes_hack);
1424      konamigx_mixer(screen, bitmap, cliprect, m_gx_psac_tilemap, GXSUB_8BPP,0,0,  0, 0, m_gx_rushingheroes_hack);
14881425   }
14891426   // hack, draw the roz tilemap if W is held
14901427   // todo: fix so that it works with the mixer without crashing(!)
1491   else if (gx_specialrozenable == 2)
1428   else if (m_gx_specialrozenable == 2)
14921429   {
14931430      // we're going to throw half of this away anyway in post-process, so only render what's needed
14941431      rectangle temprect;
14951432      temprect = cliprect;
14961433      temprect.max_x = cliprect.min_x+320;
14971434
1498      if (konamigx_type3_psac2_actual_bank == 1) K053936_0_zoom_draw(screen, *type3_roz_temp_bitmap, temprect,gx_psac_tilemap_alt, 0,0,0); // soccerss playfield
1499      else K053936_0_zoom_draw(screen, *type3_roz_temp_bitmap, temprect,gx_psac_tilemap, 0,0,0); // soccerss playfield
1435      if (konamigx_type3_psac2_actual_bank == 1) K053936_0_zoom_draw(screen, *m_type3_roz_temp_bitmap, temprect,m_gx_psac_tilemap_alt, 0,0,0); // soccerss playfield
1436      else K053936_0_zoom_draw(screen, *m_type3_roz_temp_bitmap, temprect,m_gx_psac_tilemap, 0,0,0); // soccerss playfield
15001437
15011438
1502      konamigx_mixer(screen, bitmap, cliprect, 0, 0, 0, 0, 0, type3_roz_temp_bitmap, gx_rushingheroes_hack);
1439      konamigx_mixer(screen, bitmap, cliprect, 0, 0, 0, 0, 0, m_type3_roz_temp_bitmap, m_gx_rushingheroes_hack);
15031440   }
15041441   else
15051442   {
1506      konamigx_mixer(screen, bitmap, cliprect, 0, 0, 0, 0, 0, 0, gx_rushingheroes_hack);
1443      konamigx_mixer(screen, bitmap, cliprect, 0, 0, 0, 0, 0, 0, m_gx_rushingheroes_hack);
15071444   }
15081445
15091446
15101447
15111448   /* Hack! draw type-1 roz layer here for testing purposes only */
1512   if (gx_specialrozenable == 1)
1449   if (m_gx_specialrozenable == 1)
15131450   {
15141451      const pen_t *paldata = m_palette->pens();
15151452
r241523r241524
15221459         {
15231460            for (y=0;y<256;y++)
15241461            {
1525               //UINT16* src = &gxtype1_roz_dstbitmap->pix16(y);
1462               //UINT16* src = &m_gxtype1_roz_dstbitmap->pix16(y);
15261463
15271464               //UINT32* dst = &bitmap.pix32(y);
15281465               // ths K053936 rendering should probably just be flipped
15291466               // this is just kludged to align the racing force 2d logo
1530               UINT16* src = &gxtype1_roz_dstbitmap2->pix16(y+30);
1467               UINT16* src = &m_gxtype1_roz_dstbitmap2->pix16(y+30);
15311468               UINT32* dst = &bitmap.pix32(256-y);
15321469
15331470               for (x=0;x<512;x++)
r241523r241524
15541491   {
15551492      int offset=0;
15561493
1557      if (konamigx_palformat==1)
1494      if (m_konamigx_palformat==1)
15581495      {
15591496         for (offset=0;offset<0x4000/4;offset++)
15601497         {
r241523r241524
15781515         }
15791516      }
15801517
1581      screen_update_konamigx( screen, downcast<bitmap_rgb32 &>(*dualscreen_left_tempbitmap), cliprect);
1582      copybitmap(bitmap, *dualscreen_left_tempbitmap, 0, 0, 0, 0, cliprect);
1518      screen_update_konamigx( screen, downcast<bitmap_rgb32 &>(*m_dualscreen_left_tempbitmap), cliprect);
1519      copybitmap(bitmap, *m_dualscreen_left_tempbitmap, 0, 0, 0, 0, cliprect);
15831520   }
15841521   else
15851522   {
1586      copybitmap(bitmap, *dualscreen_left_tempbitmap, 0, 0, 0, 0, cliprect);
1523      copybitmap(bitmap, *m_dualscreen_left_tempbitmap, 0, 0, 0, 0, cliprect);
15871524   }
15881525
15891526   return 0;
r241523r241524
15931530{
15941531   if (m_konamigx_current_frame==1)
15951532   {
1596      copybitmap(bitmap, *dualscreen_right_tempbitmap, 0, 0, 0, 0, cliprect);
1533      copybitmap(bitmap, *m_dualscreen_right_tempbitmap, 0, 0, 0, 0, cliprect);
15971534   }
15981535   else
15991536   {
16001537      int offset=0;
16011538
1602      if (konamigx_palformat==1)
1539      if (m_konamigx_palformat==1)
16031540      {
16041541         for (offset=0;offset<0x4000/4;offset++)
16051542         {
r241523r241524
16231560         }
16241561      }
16251562
1626      screen_update_konamigx(screen, downcast<bitmap_rgb32 &>(*dualscreen_right_tempbitmap), cliprect);
1627      copybitmap(bitmap, *dualscreen_right_tempbitmap, 0, 0, 0, 0, cliprect);
1563      screen_update_konamigx(screen, downcast<bitmap_rgb32 &>(*m_dualscreen_right_tempbitmap), cliprect);
1564      copybitmap(bitmap, *m_dualscreen_right_tempbitmap, 0, 0, 0, 0, cliprect);
16281565   }
16291566
16301567   return 0;
r241523r241524
16971634WRITE32_MEMBER(konamigx_state::konamigx_tilebank_w)
16981635{
16991636   if (ACCESSING_BITS_24_31)
1700      gx_tilebanks[offset*4] = (data>>24)&0xff;
1637      m_gx_tilebanks[offset*4] = (data>>24)&0xff;
17011638   if (ACCESSING_BITS_16_23)
1702      gx_tilebanks[offset*4+1] = (data>>16)&0xff;
1639      m_gx_tilebanks[offset*4+1] = (data>>16)&0xff;
17031640   if (ACCESSING_BITS_8_15)
1704      gx_tilebanks[offset*4+2] = (data>>8)&0xff;
1641      m_gx_tilebanks[offset*4+2] = (data>>8)&0xff;
17051642   if (ACCESSING_BITS_0_7)
1706      gx_tilebanks[offset*4+3] = data&0xff;
1643      m_gx_tilebanks[offset*4+3] = data&0xff;
17071644}
17081645
17091646// type 1 RAM-based PSAC tilemap
17101647WRITE32_MEMBER(konamigx_state::konamigx_t1_psacmap_w)
17111648{
17121649   COMBINE_DATA(&m_psacram[offset]);
1713   gx_psac_tilemap->mark_tile_dirty(offset/2);
1714   gx_psac_tilemap2->mark_tile_dirty(offset/2);
1650   m_gx_psac_tilemap->mark_tile_dirty(offset/2);
1651   m_gx_psac_tilemap2->mark_tile_dirty(offset/2);
17151652}
17161653
17171654// type 4 RAM-based PSAC tilemap
r241523r241524
17191656{
17201657   COMBINE_DATA(&m_psacram[offset]);
17211658
1722   gx_psac_tilemap->mark_tile_dirty(offset*2);
1723   gx_psac_tilemap->mark_tile_dirty((offset*2)+1);
1659   m_gx_psac_tilemap->mark_tile_dirty(offset*2);
1660   m_gx_psac_tilemap->mark_tile_dirty((offset*2)+1);
17241661}


Previous 199869 Revisions Next


© 1997-2024 The MAME Team