Previous 199869 Revisions Next

r21059 Thursday 14th February, 2013 at 10:36:12 UTC by Miodrag Milanović
Modernization of drivers part 25 (no whatsnew)
[src/mame/drivers]cyclemb.c dwarfd.c halleys.c jalmah.c jangou.c kingdrby.c ksys573.c limenko.c meritm.c multigam.c namcos11.c namcos12.c namcos23.c nightgal.c nmg5.c peplus.c seattle.c sigmab98.c taitogn.c taitotz.c tmaster.c vegas.c viper.c zn.c

trunk/src/mame/drivers/jangou.c
r21058r21059
9191   DECLARE_MACHINE_RESET(common);
9292   UINT32 screen_update_jangou(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9393   TIMER_CALLBACK_MEMBER(cvsd_bit_timer_callback);
94   UINT8 jangou_gfx_nibble( UINT16 niboffset );
95   void plot_jangou_gfx_pixel( UINT8 pix, int x, int y );
9496};
9597
9698
r21058r21059
177179w [$17]
178180*/
179181
180static UINT8 jangou_gfx_nibble( running_machine &machine, UINT16 niboffset )
182UINT8 jangou_state::jangou_gfx_nibble( UINT16 niboffset )
181183{
182   const UINT8 *const blit_rom = machine.root_device().memregion("gfx")->base();
184   const UINT8 *const blit_rom = memregion("gfx")->base();
183185
184186   if (niboffset & 1)
185187      return (blit_rom[(niboffset >> 1) & 0xffff] & 0xf0) >> 4;
r21058r21059
187189      return (blit_rom[(niboffset >> 1) & 0xffff] & 0x0f);
188190}
189191
190static void plot_jangou_gfx_pixel( running_machine &machine, UINT8 pix, int x, int y )
192void jangou_state::plot_jangou_gfx_pixel( UINT8 pix, int x, int y )
191193{
192   jangou_state *state = machine.driver_data<jangou_state>();
193194   if (y < 0 || y >= 512)
194195      return;
195196   if (x < 0 || x >= 512)
196197      return;
197198
198199   if (x & 1)
199      state->m_blit_buffer[(y * 256) + (x >> 1)] = (state->m_blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
200      m_blit_buffer[(y * 256) + (x >> 1)] = (m_blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
200201   else
201      state->m_blit_buffer[(y * 256) + (x >> 1)] = (state->m_blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
202      m_blit_buffer[(y * 256) + (x >> 1)] = (m_blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
202203}
203204
204205WRITE8_MEMBER(jangou_state::blitter_process_w)
r21058r21059
233234         {
234235            int drawx = (x + xcount) & 0xff;
235236            int drawy = (y + ycount) & 0xff;
236            UINT8 dat = jangou_gfx_nibble(machine(), src + count);
237            UINT8 dat = jangou_gfx_nibble(src + count);
237238            UINT8 cur_pen_hi = m_pen_data[(dat & 0xf0) >> 4];
238239            UINT8 cur_pen_lo = m_pen_data[(dat & 0x0f) >> 0];
239240
240241            dat = cur_pen_lo | (cur_pen_hi << 4);
241242
242243            if ((dat & 0xff) != 0)
243               plot_jangou_gfx_pixel(machine(), dat, drawx, drawy);
244               plot_jangou_gfx_pixel(dat, drawx, drawy);
244245
245246            if (!flipx)
246247               count--;
trunk/src/mame/drivers/limenko.c
r21058r21059
8888   TILE_GET_INFO_MEMBER(get_fg_tile_info);
8989   virtual void video_start();
9090   UINT32 screen_update_limenko(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
91   void draw_sprites(UINT32 *sprites, const rectangle &cliprect, int count);
92   void copy_sprites(bitmap_ind16 &bitmap, bitmap_ind16 &sprites_bitmap, bitmap_ind8 &priority_bitmap, const rectangle &cliprect);
9193};
9294
93
94static void draw_sprites(running_machine &machine, UINT32 *sprites, const rectangle &cliprect, int count);
95
9695/*****************************************************************************************************
9796  MISC FUNCTIONS
9897*****************************************************************************************************/
r21058r21059
156155   if(m_spriteram_bit)
157156   {
158157      // draw the sprites to the frame buffer
159      draw_sprites(machine(),m_spriteram2,clip,m_prev_sprites_count);
158      draw_sprites(m_spriteram2,clip,m_prev_sprites_count);
160159   }
161160   else
162161   {
163162      // draw the sprites to the frame buffer
164      draw_sprites(machine(),m_spriteram,clip,m_prev_sprites_count);
163      draw_sprites(m_spriteram,clip,m_prev_sprites_count);
165164   }
166165
167166   // buffer the next number of sprites to draw
r21058r21059
420419}
421420
422421// sprites aren't tile based (except for 8x8 ones)
423static void draw_sprites(running_machine &machine, UINT32 *sprites, const rectangle &cliprect, int count)
422void limenko_state::draw_sprites(UINT32 *sprites, const rectangle &cliprect, int count)
424423{
425   limenko_state *state = machine.driver_data<limenko_state>();
426424   int i;
427425
428   UINT8 *base_gfx = state->memregion("gfx1")->base();
429   UINT8 *gfx_max  = base_gfx + state->memregion("gfx1")->bytes();
426   UINT8 *base_gfx = memregion("gfx1")->base();
427   UINT8 *gfx_max  = base_gfx + memregion("gfx1")->bytes();
430428
431429   UINT8 *gfxdata;
432430
r21058r21059
463461         continue;
464462
465463      /* prepare GfxElement on the fly */
466      gfx_element gfx(machine, gfxdata, width, height, width, 0, 256);
464      gfx_element gfx(machine(), gfxdata, width, height, width, 0, 256);
467465
468      draw_single_sprite(state->m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y,pri);
466      draw_single_sprite(m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y,pri);
469467
470468      // wrap around x
471      draw_single_sprite(state->m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y,pri);
469      draw_single_sprite(m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y,pri);
472470
473471      // wrap around y
474      draw_single_sprite(state->m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y-512,pri);
472      draw_single_sprite(m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y-512,pri);
475473
476474      // wrap around x and y
477      draw_single_sprite(state->m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y-512,pri);
475      draw_single_sprite(m_sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y-512,pri);
478476   }
479477}
480478
481static void copy_sprites(running_machine &machine, bitmap_ind16 &bitmap, bitmap_ind16 &sprites_bitmap, bitmap_ind8 &priority_bitmap, const rectangle &cliprect)
479void limenko_state::copy_sprites(bitmap_ind16 &bitmap, bitmap_ind16 &sprites_bitmap, bitmap_ind8 &priority_bitmap, const rectangle &cliprect)
482480{
483   limenko_state *state = machine.driver_data<limenko_state>();
484481   int y;
485482   for( y=cliprect.min_y; y<=cliprect.max_y; y++ )
486483   {
487484      UINT16 *source = &sprites_bitmap.pix16(y);
488485      UINT16 *dest = &bitmap.pix16(y);
489486      UINT8 *dest_pri = &priority_bitmap.pix8(y);
490      UINT8 *source_pri = &state->m_sprites_bitmap_pri.pix8(y);
487      UINT8 *source_pri = &m_sprites_bitmap_pri.pix8(y);
491488
492489      int x;
493490      for( x=cliprect.min_x; x<=cliprect.max_x; x++ )
r21058r21059
537534   m_fg_tilemap->draw(bitmap, cliprect, 0,1);
538535
539536   if(m_videoreg[0] & 8)
540      copy_sprites(machine(), bitmap, m_sprites_bitmap, machine().priority_bitmap, cliprect);
537      copy_sprites(bitmap, m_sprites_bitmap, machine().priority_bitmap, cliprect);
541538
542539   return 0;
543540}
trunk/src/mame/drivers/dwarfd.c
r21058r21059
351351   virtual void palette_init();
352352   UINT32 screen_update_dwarfd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
353353   TIMER_DEVICE_CALLBACK_MEMBER(dwarfd_interrupt);
354   void drawCrt( bitmap_rgb32 &bitmap,const rectangle &cliprect );
354355};
355356
356357
r21058r21059
783784{
784785}
785786
786static void drawCrt( running_machine &machine, bitmap_rgb32 &bitmap,const rectangle &cliprect )
787void dwarfd_state::drawCrt( bitmap_rgb32 &bitmap,const rectangle &cliprect )
787788{
788   dwarfd_state *state = machine.driver_data<dwarfd_state>();
789789   int x, y;
790790   for (y = 0; y < maxy; y++)
791791   {
r21058r21059
804804         while (b == 0)
805805         {
806806            if (count < 0x8000)
807               tile = state->m_videobuf[count++];
807               tile = m_videobuf[count++];
808808            else
809809                  return;
810810
r21058r21059
823823               }
824824               if ((tile & 0xc0) == 0x80)
825825               {
826                  state->m_bank = (tile >> 2) & 3;
826                  m_bank = (tile >> 2) & 3;
827827               }
828828               if ((tile & 0xc0) == 0xc0)
829829               {
830830                  b = 1;
831                  tile = machine.rand() & 0x7f;//(tile >> 2) & 0xf;
831                  tile = machine().rand() & 0x7f;//(tile >> 2) & 0xf;
832832               }
833833            }
834834            else
835835               b = 1;
836836         }
837         drawgfx_transpen(bitmap, cliprect, machine.gfx[0],
838            tile + (state->m_bank + bank2) * 128,
837         drawgfx_transpen(bitmap, cliprect, machine().gfx[0],
838            tile + (m_bank + bank2) * 128,
839839            0,
840840            0, 0,
841841            x*8,y*8,0);
r21058r21059
847847UINT32 dwarfd_state::screen_update_dwarfd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
848848{
849849   bitmap.fill(get_black_pen(machine()), cliprect);
850   drawCrt(machine(), bitmap, cliprect);
850   drawCrt(bitmap, cliprect);
851851   return 0;
852852}
853853
trunk/src/mame/drivers/meritm.c
r21058r21059
245245   TIMER_DEVICE_CALLBACK_MEMBER(meritm_interrupt);
246246   TIMER_DEVICE_CALLBACK_MEMBER(vblank_start_tick);
247247   TIMER_DEVICE_CALLBACK_MEMBER(vblank_end_tick);
248   void ds1204_w( ds1204_t *ds1204, int rst, int clk, int dq );
249   int ds1204_r(ds1204_t *ds1204);
250   void ds1204_init(const UINT8* key, const UINT8* nvram);
251   void meritm_crt250_switch_banks(  );
252   void meritm_switch_banks(  );
253   UINT8 binary_to_BCD(UINT8 data);
248254};
249255
250256
r21058r21059
265271#define DS1204_STATE_WRITE_SECURITY_MATCH   3
266272#define DS1204_STATE_READ_NVRAM         4
267273
268static void ds1204_w( ds1204_t *ds1204, int rst, int clk, int dq )
274void meritm_state::ds1204_w( ds1204_t *ds1204, int rst, int clk, int dq )
269275{
270276   //logerror("ds1204_w: rst = %d, clk = %d, dq = %d\n", rst, clk, dq );
271277   if ( rst == 0 )
r21058r21059
344350   }
345351};
346352
347static int ds1204_r(ds1204_t *ds1204)
353int meritm_state::ds1204_r(ds1204_t *ds1204)
348354{
349355   //logerror("ds1204_r\n");
350356   return ds1204->out_bit;
351357};
352358
353static void ds1204_init(running_machine &machine, const UINT8* key, const UINT8* nvram)
359void meritm_state::ds1204_init(const UINT8* key, const UINT8* nvram)
354360{
355   meritm_state *state = machine.driver_data<meritm_state>();
356   memset(&state->m_ds1204, 0, sizeof(state->m_ds1204));
361   memset(&m_ds1204, 0, sizeof(m_ds1204));
357362   if (key)
358      memcpy(state->m_ds1204.key, key, sizeof(state->m_ds1204.key));
363      memcpy(m_ds1204.key, key, sizeof(m_ds1204.key));
359364   if (nvram)
360      memcpy(state->m_ds1204.nvram, nvram, sizeof(state->m_ds1204.nvram));
365      memcpy(m_ds1204.nvram, nvram, sizeof(m_ds1204.nvram));
361366
362   state_save_register_item(machine, "ds1204", NULL, 0, state->m_ds1204.state);
363   state_save_register_item(machine, "ds1204", NULL, 0, state->m_ds1204.read_ptr);
364   state_save_register_item(machine, "ds1204", NULL, 0, state->m_ds1204.last_clk);
365   state_save_register_item(machine, "ds1204", NULL, 0, state->m_ds1204.out_bit);
366   state_save_register_item_array(machine, "ds1204", NULL, 0, state->m_ds1204.command);
367   state_save_register_item(machine(), "ds1204", NULL, 0, m_ds1204.state);
368   state_save_register_item(machine(), "ds1204", NULL, 0, m_ds1204.read_ptr);
369   state_save_register_item(machine(), "ds1204", NULL, 0, m_ds1204.last_clk);
370   state_save_register_item(machine(), "ds1204", NULL, 0, m_ds1204.out_bit);
371   state_save_register_item_array(machine(), "ds1204", NULL, 0, m_ds1204.command);
367372};
368373
369374/*************************************
r21058r21059
498503 *************************************/
499504
500505
501static void meritm_crt250_switch_banks( running_machine &machine )
506void meritm_state::meritm_crt250_switch_banks(  )
502507{
503   meritm_state *state = machine.driver_data<meritm_state>();
504   int rombank = (state->m_bank & 0x07) ^ 0x07;
508   int rombank = (m_bank & 0x07) ^ 0x07;
505509
506   //logerror( "CRT250: Switching banks: rom = %0x (bank = %x)\n", rombank, state->m_bank );
507   state->membank("bank1")->set_entry(rombank );
510   //logerror( "CRT250: Switching banks: rom = %0x (bank = %x)\n", rombank, m_bank );
511   membank("bank1")->set_entry(rombank );
508512};
509513
510514WRITE8_MEMBER(meritm_state::meritm_crt250_bank_w)
511515{
512   meritm_crt250_switch_banks(machine());
516   meritm_crt250_switch_banks();
513517};
514518
515static void meritm_switch_banks( running_machine &machine )
519void meritm_state::meritm_switch_banks(  )
516520{
517   meritm_state *state = machine.driver_data<meritm_state>();
518   int rambank = (state->m_psd_a15 >> 2) & 0x3;
519   int rombank = (((state->m_bank >> 3) & 0x3) << 5) |
520            (((state->m_psd_a15 >> 1) & 0x1) << 4) |
521            (((state->m_bank & 0x07) ^ 0x07) << 1) |
522            (state->m_psd_a15 & 0x1);
521   int rambank = (m_psd_a15 >> 2) & 0x3;
522   int rombank = (((m_bank >> 3) & 0x3) << 5) |
523            (((m_psd_a15 >> 1) & 0x1) << 4) |
524            (((m_bank & 0x07) ^ 0x07) << 1) |
525            (m_psd_a15 & 0x1);
523526
524   //logerror( "Switching banks: rom = %0x (bank = %x), ram = %0x\n", rombank, state->m_bank, rambank);
525   state->membank("bank1")->set_entry(rombank );
526   state->membank("bank2")->set_entry(rombank | 0x01);
527   state->membank("bank3")->set_entry(rambank);
527   //logerror( "Switching banks: rom = %0x (bank = %x), ram = %0x\n", rombank, m_bank, rambank);
528   membank("bank1")->set_entry(rombank );
529   membank("bank2")->set_entry(rombank | 0x01);
530   membank("bank3")->set_entry(rambank);
528531};
529532
530533WRITE8_MEMBER(meritm_state::meritm_psd_a15_w)
531534{
532535   m_psd_a15 = data;
533536   //logerror( "Writing PSD_A15 with %02x at PC=%04X\n", data, space.device().safe_pc() );
534   meritm_switch_banks(machine());
537   meritm_switch_banks();
535538};
536539
537540WRITE8_MEMBER(meritm_state::meritm_bank_w)
538541{
539   meritm_switch_banks(machine());
542   meritm_switch_banks();
540543};
541544
542545/*************************************
r21058r21059
626629   }
627630};
628631
629static UINT8 binary_to_BCD(UINT8 data)
632UINT8 meritm_state::binary_to_BCD(UINT8 data)
630633{
631634   data %= 100;
632635
r21058r21059
11071110{
11081111   membank("bank1")->configure_entries(0, 8, memregion("maincpu")->base(), 0x10000);
11091112   m_bank = 0xff;
1110   meritm_crt250_switch_banks(machine());
1113   meritm_crt250_switch_banks();
11111114   MACHINE_START_CALL_MEMBER(merit_common);
11121115   state_save_register_global(machine(), m_bank);
11131116
r21058r21059
11351138   membank("bank3")->configure_entries(0, 4, m_ram, 0x2000);
11361139   m_bank = 0xff;
11371140   m_psd_a15 = 0;
1138   meritm_switch_banks(machine());
1141   meritm_switch_banks();
11391142   MACHINE_START_CALL_MEMBER(merit_common);
11401143   pc16552d_init(machine(), 0, UART_CLK, NULL, pc16650d_tx_callback);
11411144   state_save_register_global(machine(), m_bank);
r21058r21059
20032006   static const UINT8 pitbossm_ds1204_nvram[16] =
20042007      { 0x16, 0x90, 0xa0, 0x52, 0xd8, 0x6c, 0x12, 0xaf, 0x36, 0x22, 0x61, 0x35, 0x0d, 0x58, 0x0c, 0x00 };
20052008
2006   ds1204_init(machine(), pitbossm_ds1204_key, pitbossm_ds1204_nvram);
2009   ds1204_init(pitbossm_ds1204_key, pitbossm_ds1204_nvram);
20072010
20082011};
20092012
r21058r21059
20152018   static const UINT8 pbst30b_ds1204_nvram[16] =
20162019      { 0x3e, 0x9a, 0x3c, 0x3f, 0x1d, 0x51, 0x72, 0xc9, 0x28, 0x2c, 0x1d, 0x2d, 0x0e, 0x56, 0x41, 0x00 };
20172020
2018   ds1204_init(machine(), pbst30b_ds1204_key, pbst30b_ds1204_nvram);
2021   ds1204_init(pbst30b_ds1204_key, pbst30b_ds1204_nvram);
20192022
20202023};
20212024
r21058r21059
20272030   static const UINT8 pbst30b_ds1204_nvram[16] =
20282031      { 0xa9, 0xdb, 0x41, 0xf8, 0xe4, 0x42, 0x20, 0x6e, 0xde, 0xaf, 0x4f, 0x046, 0x3d, 0x55, 0x44, 0x00 };
20292032
2030   ds1204_init(machine(), pbst30b_ds1204_key, pbst30b_ds1204_nvram);
2033   ds1204_init(pbst30b_ds1204_key, pbst30b_ds1204_nvram);
20312034
20322035};
20332036
r21058r21059
20392042   static const UINT8 pitbosmt_ds1204_nvram[16] =
20402043      { 0x00, 0xfe, 0x03, 0x03, 0x08, 0x00, 0xa2, 0x03, 0x4b, 0x07, 0x00, 0xe6, 0x02, 0xd3, 0x05, 0x00 };
20412044
2042   ds1204_init(machine(), pitbosmt_ds1204_key, pitbosmt_ds1204_nvram);
2045   ds1204_init(pitbosmt_ds1204_key, pitbosmt_ds1204_nvram);
20432046
20442047};
20452048
r21058r21059
20512054   static const UINT8 megat3_ds1204_nvram[16] =
20522055      { 0x51, 0xa1, 0xc0, 0x7c, 0x27, 0x6e, 0x51, 0xb9, 0xa5, 0xb2, 0x27, 0x0c, 0xb9, 0x88, 0x82, 0x2c };
20532056
2054   ds1204_init(machine(), megat3_ds1204_key, megat3_ds1204_nvram);
2057   ds1204_init(megat3_ds1204_key, megat3_ds1204_nvram);
20552058
20562059};
20572060
r21058r21059
20632066   static const UINT8 megat3_ds1204_nvram[16] =
20642067      { 0x99, 0x53, 0xfc, 0x29, 0x3a, 0x95, 0x8b, 0x58, 0xca, 0xca, 0x00, 0xc2, 0x30, 0x62, 0x0b, 0x96 };
20652068
2066   ds1204_init(machine(), megat3_ds1204_key, megat3_ds1204_nvram);
2069   ds1204_init(megat3_ds1204_key, megat3_ds1204_nvram);
20672070
20682071   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xfff8, 0xffff, read8_delegate(FUNC(meritm_state::meritm_ds1644_r), this), write8_delegate(FUNC(meritm_state::meritm_ds1644_w), this));
20692072
r21058r21059
20742077   static const UINT8 megat4_ds1204_nvram[16] =
20752078      { 0xe3, 0x08, 0x39, 0xd8, 0x4c, 0xbb, 0xc4, 0xf8, 0xf0, 0xe2, 0xd8, 0x77, 0xa8, 0x3d, 0x95, 0x02 };
20762079
2077   ds1204_init(machine(), 0, megat4_ds1204_nvram);
2080   ds1204_init(0, megat4_ds1204_nvram);
20782081}
20792082
20802083DRIVER_INIT_MEMBER(meritm_state,megat4c)
r21058r21059
20852088   static const UINT8 megat4_ds1204_nvram[16] =
20862089      { 0xe3, 0x08, 0x39, 0xd8, 0x4c, 0xbb, 0xc4, 0xf8, 0xf0, 0xe2, 0xd8, 0x77, 0xa8, 0x3d, 0x95, 0x02 };
20872090
2088   ds1204_init(machine(), megat4c_ds1204_key, megat4_ds1204_nvram);
2091   ds1204_init(megat4c_ds1204_key, megat4_ds1204_nvram);
20892092}
20902093
20912094DRIVER_INIT_MEMBER(meritm_state,megat4te)
r21058r21059
20932096   static const UINT8 megat4te_ds1204_nvram[16] =
20942097      { 0x05, 0x21, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
20952098
2096   ds1204_init(machine(), 0, megat4te_ds1204_nvram);
2099   ds1204_init(0, megat4te_ds1204_nvram);
20972100
20982101   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xfff8, 0xffff, read8_delegate(FUNC(meritm_state::meritm_ds1644_r), this), write8_delegate(FUNC(meritm_state::meritm_ds1644_w), this));
20992102
r21058r21059
21042107   static const UINT8 megat4te_ds1204_nvram[16] =
21052108      { 0x11, 0x04, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
21062109
2107   ds1204_init(machine(), 0, megat4te_ds1204_nvram);
2110   ds1204_init(0, megat4te_ds1204_nvram);
21082111
21092112   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xfff8, 0xffff, read8_delegate(FUNC(meritm_state::meritm_ds1644_r), this), write8_delegate(FUNC(meritm_state::meritm_ds1644_w), this));
21102113
r21058r21059
21152118   static const UINT8 megat5_ds1204_nvram[16] =
21162119      { 0x06, 0x23, 0x97, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
21172120
2118   ds1204_init(machine(), 0, megat5_ds1204_nvram);
2121   ds1204_init(0, megat5_ds1204_nvram);
21192122
21202123}
21212124
r21058r21059
21242127   static const UINT8 megat5_ds1204_nvram[16] =
21252128      { 0x08, 0x22, 0x97, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
21262129
2127   ds1204_init(machine(), 0, megat5_ds1204_nvram);
2130   ds1204_init(0, megat5_ds1204_nvram);
21282131
21292132   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xfff8, 0xffff, read8_delegate(FUNC(meritm_state::meritm_ds1644_r), this), write8_delegate(FUNC(meritm_state::meritm_ds1644_w), this));
21302133
r21058r21059
21352138   static const UINT8 megat6_ds1204_nvram[16] =
21362139      { 0x07, 0x15, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
21372140
2138   ds1204_init(machine(), 0, megat6_ds1204_nvram);
2141   ds1204_init(0, megat6_ds1204_nvram);
21392142
21402143}
21412144
trunk/src/mame/drivers/seattle.c
r21058r21059
496496   virtual void machine_reset();
497497   UINT32 screen_update_seattle(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
498498   TIMER_CALLBACK_MEMBER(galileo_timer_callback);
499   void ethernet_interrupt_machine(int state);
500   void update_vblank_irq();
501   UINT32 pci_bridge_r(address_space &space, UINT8 reg, UINT8 type);
502   void pci_bridge_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data);
503   UINT32 pci_3dfx_r(address_space &space, UINT8 reg, UINT8 type);
504   void pci_3dfx_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data);
505   UINT32 pci_ide_r(address_space &space, UINT8 reg, UINT8 type);
506   void pci_ide_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data);
507   void update_galileo_irqs();
508   int galileo_dma_fetch_next(address_space &space, int which);
509   void galileo_perform_dma(address_space &space, int which);
510   void galileo_reset();
511   void widget_reset();
512   void update_widget_irq();
513   void init_common(int ioasic, int serialnum, int yearoffs, int config);
499514};
500515
501
502516/*************************************
503517 *
504 *  Prototypes
505 *
506 *************************************/
507
508static void vblank_assert(device_t *device, int state);
509static void update_vblank_irq(running_machine &machine);
510static void galileo_reset(running_machine &machine);
511
512static void galileo_perform_dma(address_space &space, int which);
513static void voodoo_stall(device_t *device, int stall);
514static void widget_reset(running_machine &machine);
515static void update_widget_irq(running_machine &machine);
516
517
518
519/*************************************
520 *
521518 *  Video start and update
522519 *
523520 *************************************/
r21058r21059
607604   }
608605
609606   /* reset the other devices */
610   galileo_reset(machine());
607   galileo_reset();
611608   if (m_board_config == SEATTLE_WIDGET_CONFIG)
612      widget_reset(machine());
609      widget_reset();
613610}
614611
615612
r21058r21059
633630 *
634631 *************************************/
635632
636static void ethernet_interrupt_machine(running_machine &machine, int state)
633void seattle_state::ethernet_interrupt_machine(int state)
637634{
638   seattle_state *drvstate = machine.driver_data<seattle_state>();
639   drvstate->m_ethernet_irq_state = state;
640   if (drvstate->m_board_config == FLAGSTAFF_CONFIG)
635   m_ethernet_irq_state = state;
636   if (m_board_config == FLAGSTAFF_CONFIG)
641637   {
642      UINT8 assert = drvstate->m_ethernet_irq_state && (*drvstate->m_interrupt_enable & (1 << ETHERNET_IRQ_SHIFT));
643      if (drvstate->m_ethernet_irq_num != 0)
644         machine.device("maincpu")->execute().set_input_line(drvstate->m_ethernet_irq_num, assert ? ASSERT_LINE : CLEAR_LINE);
638      UINT8 assert = m_ethernet_irq_state && (*m_interrupt_enable & (1 << ETHERNET_IRQ_SHIFT));
639      if (m_ethernet_irq_num != 0)
640         machine().device("maincpu")->execute().set_input_line(m_ethernet_irq_num, assert ? ASSERT_LINE : CLEAR_LINE);
645641   }
646   else if (drvstate->m_board_config == SEATTLE_WIDGET_CONFIG)
647      update_widget_irq(machine);
642   else if (m_board_config == SEATTLE_WIDGET_CONFIG)
643      update_widget_irq();
648644}
649645
650646static void ethernet_interrupt(device_t *device, int state)
651647{
652   ethernet_interrupt_machine(device->machine(), state);
648   seattle_state *drvstate = device->machine().driver_data<seattle_state>();
649   drvstate->ethernet_interrupt_machine(state);
653650}
654651
655652
r21058r21059
728725   }
729726
730727   /* update the states */
731   update_vblank_irq(machine());
732   ethernet_interrupt_machine(machine(), m_ethernet_irq_state);
728   update_vblank_irq();
729   ethernet_interrupt_machine(m_ethernet_irq_state);
733730}
734731
735732
r21058r21059
740737   if (old != *m_interrupt_enable)
741738   {
742739      if (m_vblank_latch)
743         update_vblank_irq(machine());
740         update_vblank_irq();
744741      if (m_ethernet_irq_state)
745         ethernet_interrupt_machine(machine(), m_ethernet_irq_state);
742         ethernet_interrupt_machine(m_ethernet_irq_state);
746743   }
747744}
748745
r21058r21059
754751 *
755752 *************************************/
756753
757static void update_vblank_irq(running_machine &machine)
754void seattle_state::update_vblank_irq()
758755{
759   seattle_state *drvstate = machine.driver_data<seattle_state>();
760756   int state = CLEAR_LINE;
761757
762758   /* skip if no interrupt configured */
763   if (drvstate->m_vblank_irq_num == 0)
759   if (m_vblank_irq_num == 0)
764760      return;
765761
766762   /* if the VBLANK has been latched, and the interrupt is enabled, assert */
767   if (drvstate->m_vblank_latch && (*drvstate->m_interrupt_enable & (1 << VBLANK_IRQ_SHIFT)))
763   if (m_vblank_latch && (*m_interrupt_enable & (1 << VBLANK_IRQ_SHIFT)))
768764      state = ASSERT_LINE;
769   machine.device("maincpu")->execute().set_input_line(drvstate->m_vblank_irq_num, state);
765   machine().device("maincpu")->execute().set_input_line(m_vblank_irq_num, state);
770766}
771767
772768
r21058r21059
774770{
775771   /* clear the latch and update the IRQ */
776772   m_vblank_latch = 0;
777   update_vblank_irq(machine());
773   update_vblank_irq();
778774}
779775
780776
r21058r21059
788784   if ((state && !(*drvstate->m_interrupt_enable & 0x100)) || (!state && (*drvstate->m_interrupt_enable & 0x100)))
789785   {
790786      drvstate->m_vblank_latch = 1;
791      update_vblank_irq(device->machine());
787      drvstate->update_vblank_irq();
792788   }
793789}
794790
r21058r21059
800796 *
801797 *************************************/
802798
803static UINT32 pci_bridge_r(address_space &space, UINT8 reg, UINT8 type)
799UINT32 seattle_state::pci_bridge_r(address_space &space, UINT8 reg, UINT8 type)
804800{
805   seattle_state *state = space.machine().driver_data<seattle_state>();
806   UINT32 result = state->m_galileo.pci_bridge_regs[reg];
801   UINT32 result = m_galileo.pci_bridge_regs[reg];
807802
808803   switch (reg)
809804   {
r21058r21059
822817}
823818
824819
825static void pci_bridge_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data)
826{
827   seattle_state *state = space.machine().driver_data<seattle_state>();
828   state->m_galileo.pci_bridge_regs[reg] = data;
820void seattle_state::pci_bridge_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data)
821{   
822   m_galileo.pci_bridge_regs[reg] = data;
829823   if (LOG_PCI)
830824      logerror("%08X:PCI bridge write: reg %d type %d = %08X\n", space.device().safe_pc(), reg, type, data);
831825}
r21058r21059
838832 *
839833 *************************************/
840834
841static UINT32 pci_3dfx_r(address_space &space, UINT8 reg, UINT8 type)
842{
843   seattle_state *state = space.machine().driver_data<seattle_state>();
844   UINT32 result = state->m_galileo.pci_3dfx_regs[reg];
835UINT32 seattle_state::pci_3dfx_r(address_space &space, UINT8 reg, UINT8 type)
836{   
837   UINT32 result = m_galileo.pci_3dfx_regs[reg];
845838
846839   switch (reg)
847840   {
r21058r21059
860853}
861854
862855
863static void pci_3dfx_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data)
856void seattle_state::pci_3dfx_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data)
864857{
865   seattle_state *state = space.machine().driver_data<seattle_state>();
866   state->m_galileo.pci_3dfx_regs[reg] = data;
858   m_galileo.pci_3dfx_regs[reg] = data;
867859
868860   switch (reg)
869861   {
870862      case 0x04:      /* address register */
871         state->m_galileo.pci_3dfx_regs[reg] &= 0xff000000;
863         m_galileo.pci_3dfx_regs[reg] &= 0xff000000;
872864         if (data != 0x08000000)
873865            logerror("3dfx not mapped where we expect it! (%08X)\n", data);
874866         break;
875867
876868      case 0x10:      /* initEnable register */
877         voodoo_set_init_enable(state->m_voodoo, data);
869         voodoo_set_init_enable(m_voodoo, data);
878870         break;
879871   }
880872   if (LOG_PCI)
r21058r21059
889881 *
890882 *************************************/
891883
892static UINT32 pci_ide_r(address_space &space, UINT8 reg, UINT8 type)
884UINT32 seattle_state::pci_ide_r(address_space &space, UINT8 reg, UINT8 type)
893885{
894   seattle_state *state = space.machine().driver_data<seattle_state>();
895   UINT32 result = state->m_galileo.pci_ide_regs[reg];
886   UINT32 result = m_galileo.pci_ide_regs[reg];
896887
897888   switch (reg)
898889   {
r21058r21059
911902}
912903
913904
914static void pci_ide_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data)
905void seattle_state::pci_ide_w(address_space &space, UINT8 reg, UINT8 type, UINT32 data)
915906{
916   seattle_state *state = space.machine().driver_data<seattle_state>();
917   state->m_galileo.pci_ide_regs[reg] = data;
907   m_galileo.pci_ide_regs[reg] = data;
918908   if (LOG_PCI)
919909      logerror("%08X:PCI bridge write: reg %d type %d = %08X\n", space.device().safe_pc(), reg, type, data);
920910}
r21058r21059
927917 *
928918 *************************************/
929919
930static void update_galileo_irqs(running_machine &machine)
920void seattle_state::update_galileo_irqs()
931921{
932   seattle_state *drvstate = machine.driver_data<seattle_state>();
933922   int state = CLEAR_LINE;
934923
935924   /* if any unmasked interrupts are live, we generate */
936   if (drvstate->m_galileo.reg[GREG_INT_STATE] & drvstate->m_galileo.reg[GREG_INT_MASK])
925   if (m_galileo.reg[GREG_INT_STATE] & m_galileo.reg[GREG_INT_MASK])
937926      state = ASSERT_LINE;
938   machine.device("maincpu")->execute().set_input_line(GALILEO_IRQ_NUM, state);
927   machine().device("maincpu")->execute().set_input_line(GALILEO_IRQ_NUM, state);
939928
940929   if (LOG_GALILEO)
941930      logerror("Galileo IRQ %s\n", (state == ASSERT_LINE) ? "asserted" : "cleared");
r21058r21059
963952
964953   /* trigger the interrupt */
965954   m_galileo.reg[GREG_INT_STATE] |= 1 << (GINT_T0EXP_SHIFT + which);
966   update_galileo_irqs(machine());
955   update_galileo_irqs();
967956}
968957
969958
r21058r21059
974963 *
975964 *************************************/
976965
977static int galileo_dma_fetch_next(address_space &space, int which)
966int seattle_state::galileo_dma_fetch_next(address_space &space, int which)
978967{
979   seattle_state *state = space.machine().driver_data<seattle_state>();
980   galileo_data &galileo = state->m_galileo;
968   galileo_data &galileo = m_galileo;
981969   offs_t address = 0;
982970   UINT32 data;
983971
r21058r21059
991979      if (galileo.reg[GREG_DMA0_CONTROL + which] & 0x400)
992980      {
993981         galileo.reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which);
994         update_galileo_irqs(space.machine());
982         update_galileo_irqs();
995983      }
996984      galileo.reg[GREG_DMA0_CONTROL + which] &= ~0x5000;
997985      return 0;
r21058r21059
10161004}
10171005
10181006
1019static void galileo_perform_dma(address_space &space, int which)
1007void seattle_state::galileo_perform_dma(address_space &space, int which)
10201008{
1021   seattle_state *state = space.machine().driver_data<seattle_state>();
1022   galileo_data &galileo = state->m_galileo;
1009   galileo_data &galileo = m_galileo;
10231010   do
10241011   {
10251012      offs_t srcaddr = galileo.reg[GREG_DMA0_SOURCE + which];
r21058r21059
10611048         while (bytesleft >= 4)
10621049         {
10631050            /* if the voodoo is stalled, stop early */
1064            if (state->m_voodoo_stalled)
1051            if (m_voodoo_stalled)
10651052            {
10661053               if (LOG_DMA)
10671054                  logerror("Stalled on voodoo with %d bytes left\n", bytesleft);
r21058r21059
10691056            }
10701057
10711058            /* write the data and advance */
1072            voodoo_w(state->m_voodoo, space, (dstaddr & 0xffffff) / 4, space.read_dword(srcaddr), 0xffffffff);
1059            voodoo_w(m_voodoo, space, (dstaddr & 0xffffff) / 4, space.read_dword(srcaddr), 0xffffffff);
10731060            srcaddr += srcinc;
10741061            dstaddr += dstinc;
10751062            bytesleft -= 4;
r21058r21059
11021089      if (!(galileo.reg[GREG_DMA0_CONTROL + which] & 0x400))
11031090      {
11041091         galileo.reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which);
1105         update_galileo_irqs(space.machine());
1092         update_galileo_irqs();
11061093      }
11071094   } while (galileo_dma_fetch_next(space, which));
11081095
r21058r21059
11171104 *
11181105 *************************************/
11191106
1120static void galileo_reset(running_machine &machine)
1107void seattle_state::galileo_reset()
11211108{
1122   seattle_state *state = machine.driver_data<seattle_state>();
1123   memset(&state->m_galileo.reg, 0, sizeof(state->m_galileo.reg));
1109   memset(&m_galileo.reg, 0, sizeof(m_galileo.reg));
11241110}
11251111
11261112
r21058r21059
12961282         if (LOG_GALILEO)
12971283            logerror("%08X:Galileo write to IRQ clear = %08X & %08X\n", offset*4, data, mem_mask);
12981284         galileo.reg[offset] = oldata & data;
1299         update_galileo_irqs(machine());
1285         update_galileo_irqs();
13001286         break;
13011287
13021288      case GREG_CONFIG_DATA:
r21058r21059
14111397            state->m_galileo.dma_stalled_on_voodoo[which] = FALSE;
14121398
14131399            /* resume execution */
1414            galileo_perform_dma(space, which);
1400            state->galileo_perform_dma(space, which);
14151401            break;
14161402         }
14171403
r21058r21059
15501536 *
15511537 *************************************/
15521538
1553static void widget_reset(running_machine &machine)
1539void seattle_state::widget_reset()
15541540{
1555   seattle_state *state = machine.driver_data<seattle_state>();
1556   UINT8 saved_irq = state->m_widget.irq_num;
1557   memset(&state->m_widget, 0, sizeof(state->m_widget));
1558   state->m_widget.irq_num = saved_irq;
1541   UINT8 saved_irq = m_widget.irq_num;
1542   memset(&m_widget, 0, sizeof(m_widget));
1543   m_widget.irq_num = saved_irq;
15591544}
15601545
15611546
1562static void update_widget_irq(running_machine &machine)
1547void seattle_state::update_widget_irq()
15631548{
1564   seattle_state *drvstate = machine.driver_data<seattle_state>();
1565   UINT8 state = drvstate->m_ethernet_irq_state << WINT_ETHERNET_SHIFT;
1566   UINT8 mask = drvstate->m_widget.irq_mask;
1567   UINT8 assert = ((mask & state) != 0) && (*drvstate->m_interrupt_enable & (1 << WIDGET_IRQ_SHIFT));
1549   UINT8 state = m_ethernet_irq_state << WINT_ETHERNET_SHIFT;
1550   UINT8 mask = m_widget.irq_mask;
1551   UINT8 assert = ((mask & state) != 0) && (*m_interrupt_enable & (1 << WIDGET_IRQ_SHIFT));
15681552
15691553   /* update the IRQ state */
1570   if (drvstate->m_widget.irq_num != 0)
1571      machine.device("maincpu")->execute().set_input_line(drvstate->m_widget.irq_num, assert ? ASSERT_LINE : CLEAR_LINE);
1554   if (m_widget.irq_num != 0)
1555      machine().device("maincpu")->execute().set_input_line(m_widget.irq_num, assert ? ASSERT_LINE : CLEAR_LINE);
15721556}
15731557
15741558
r21058r21059
16171601
16181602      case WREG_INTERRUPT:
16191603         m_widget.irq_mask = data;
1620         update_widget_irq(machine());
1604         update_widget_irq();
16211605         break;
16221606
16231607      case WREG_ANALOG:
r21058r21059
28562840 *
28572841 *************************************/
28582842
2859static void init_common(running_machine &machine, int ioasic, int serialnum, int yearoffs, int config)
2843void seattle_state::init_common(int ioasic, int serialnum, int yearoffs, int config)
28602844{
2861   seattle_state *state = machine.driver_data<seattle_state>();
28622845
28632846   /* initialize the subsystems */
2864   midway_ioasic_init(machine, ioasic, serialnum, yearoffs, ioasic_irq);
2847   midway_ioasic_init(machine(),ioasic, serialnum, yearoffs, ioasic_irq);
28652848
28662849   /* switch off the configuration */
2867   state->m_board_config = config;
2850   m_board_config = config;
28682851   switch (config)
28692852   {
28702853      case PHOENIX_CONFIG:
28712854         /* original Phoenix board only has 4MB of RAM */
2872         machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_readwrite(0x00400000, 0x007fffff);
2855         machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_readwrite(0x00400000, 0x007fffff);
28732856         break;
28742857
28752858      case SEATTLE_WIDGET_CONFIG:
28762859         /* set up the widget board */
2877         machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x16c00000, 0x16c0001f, read32_delegate(FUNC(seattle_state::widget_r),state), write32_delegate(FUNC(seattle_state::widget_w),state));
2860         machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x16c00000, 0x16c0001f, read32_delegate(FUNC(seattle_state::widget_r),this), write32_delegate(FUNC(seattle_state::widget_w),this));
28782861         break;
28792862
28802863      case FLAGSTAFF_CONFIG:
28812864         /* set up the analog inputs */
2882         machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x14000000, 0x14000003, read32_delegate(FUNC(seattle_state::analog_port_r),state), write32_delegate(FUNC(seattle_state::analog_port_w),state));
2865         machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x14000000, 0x14000003, read32_delegate(FUNC(seattle_state::analog_port_r),this), write32_delegate(FUNC(seattle_state::analog_port_w),this));
28832866
28842867         /* set up the ethernet controller */
2885         machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x16c00000, 0x16c0003f, read32_delegate(FUNC(seattle_state::ethernet_r),state), write32_delegate(FUNC(seattle_state::ethernet_w),state));
2868         machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x16c00000, 0x16c0003f, read32_delegate(FUNC(seattle_state::ethernet_r),this), write32_delegate(FUNC(seattle_state::ethernet_w),this));
28862869         break;
28872870   }
28882871}
r21058r21059
28912874DRIVER_INIT_MEMBER(seattle_state,wg3dh)
28922875{
28932876   dcs2_init(machine(), 2, 0x3839);
2894   init_common(machine(), MIDWAY_IOASIC_STANDARD, 310/* others? */, 80, PHOENIX_CONFIG);
2877   init_common(MIDWAY_IOASIC_STANDARD, 310/* others? */, 80, PHOENIX_CONFIG);
28952878
28962879   /* speedups */
28972880   mips3drc_add_hotspot(machine().device("maincpu"), 0x8004413C, 0x0C0054B4, 250);     /* confirmed */
r21058r21059
29032886DRIVER_INIT_MEMBER(seattle_state,mace)
29042887{
29052888   dcs2_init(machine(), 2, 0x3839);
2906   init_common(machine(), MIDWAY_IOASIC_MACE, 319/* others? */, 80, SEATTLE_CONFIG);
2889   init_common(MIDWAY_IOASIC_MACE, 319/* others? */, 80, SEATTLE_CONFIG);
29072890
29082891   /* speedups */
29092892   mips3drc_add_hotspot(machine().device("maincpu"), 0x800108F8, 0x8C420000, 250);     /* confirmed */
r21058r21059
29132896DRIVER_INIT_MEMBER(seattle_state,sfrush)
29142897{
29152898   cage_init(machine(), 0x5236);
2916   init_common(machine(), MIDWAY_IOASIC_STANDARD, 315/* no alternates */, 100, FLAGSTAFF_CONFIG);
2899   init_common(MIDWAY_IOASIC_STANDARD, 315/* no alternates */, 100, FLAGSTAFF_CONFIG);
29172900
29182901   /* speedups */
29192902   mips3drc_add_hotspot(machine().device("maincpu"), 0x80059F34, 0x3C028012, 250);     /* confirmed */
r21058r21059
29252908DRIVER_INIT_MEMBER(seattle_state,sfrushrk)
29262909{
29272910   cage_init(machine(), 0x5329);
2928   init_common(machine(), MIDWAY_IOASIC_SFRUSHRK, 331/* unknown */, 100, FLAGSTAFF_CONFIG);
2911   init_common(MIDWAY_IOASIC_SFRUSHRK, 331/* unknown */, 100, FLAGSTAFF_CONFIG);
29292912
29302913   /* speedups */
29312914   mips3drc_add_hotspot(machine().device("maincpu"), 0x800343E8, 0x3C028012, 250);     /* confirmed */
r21058r21059
29382921DRIVER_INIT_MEMBER(seattle_state,calspeed)
29392922{
29402923   dcs2_init(machine(), 2, 0x39c0);
2941   init_common(machine(), MIDWAY_IOASIC_CALSPEED, 328/* others? */, 100, SEATTLE_WIDGET_CONFIG);
2924   init_common(MIDWAY_IOASIC_CALSPEED, 328/* others? */, 100, SEATTLE_WIDGET_CONFIG);
29422925   midway_ioasic_set_auto_ack(1);
29432926
29442927   /* speedups */
r21058r21059
29502933DRIVER_INIT_MEMBER(seattle_state,vaportrx)
29512934{
29522935   dcs2_init(machine(), 2, 0x39c2);
2953   init_common(machine(), MIDWAY_IOASIC_VAPORTRX, 324/* 334? unknown */, 100, SEATTLE_WIDGET_CONFIG);
2936   init_common(MIDWAY_IOASIC_VAPORTRX, 324/* 334? unknown */, 100, SEATTLE_WIDGET_CONFIG);
29542937
29552938   /* speedups */
29562939   mips3drc_add_hotspot(machine().device("maincpu"), 0x80049F14, 0x3C028020, 250);     /* confirmed */
r21058r21059
29622945DRIVER_INIT_MEMBER(seattle_state,biofreak)
29632946{
29642947   dcs2_init(machine(), 2, 0x3835);
2965   init_common(machine(), MIDWAY_IOASIC_STANDARD, 231/* no alternates */, 80, SEATTLE_CONFIG);
2948   init_common(MIDWAY_IOASIC_STANDARD, 231/* no alternates */, 80, SEATTLE_CONFIG);
29662949
29672950   /* speedups */
29682951}
r21058r21059
29712954DRIVER_INIT_MEMBER(seattle_state,blitz)
29722955{
29732956   dcs2_init(machine(), 2, 0x39c2);
2974   init_common(machine(), MIDWAY_IOASIC_BLITZ99, 444/* or 528 */, 80, SEATTLE_CONFIG);
2957   init_common(MIDWAY_IOASIC_BLITZ99, 444/* or 528 */, 80, SEATTLE_CONFIG);
29752958
29762959   /* for some reason, the code in the ROM appears buggy; this is a small patch to fix it */
29772960   m_rombase[0x934/4] += 4;
r21058r21059
29852968DRIVER_INIT_MEMBER(seattle_state,blitz99)
29862969{
29872970   dcs2_init(machine(), 2, 0x0afb);
2988   init_common(machine(), MIDWAY_IOASIC_BLITZ99, 481/* or 484 or 520 */, 80, SEATTLE_CONFIG);
2971   init_common(MIDWAY_IOASIC_BLITZ99, 481/* or 484 or 520 */, 80, SEATTLE_CONFIG);
29892972
29902973   /* speedups */
29912974   mips3drc_add_hotspot(machine().device("maincpu"), 0x8014E41C, 0x3C038025, 250);     /* confirmed */
r21058r21059
29962979DRIVER_INIT_MEMBER(seattle_state,blitz2k)
29972980{
29982981   dcs2_init(machine(), 2, 0x0b5d);
2999   init_common(machine(), MIDWAY_IOASIC_BLITZ99, 494/* or 498 */, 80, SEATTLE_CONFIG);
2982   init_common(MIDWAY_IOASIC_BLITZ99, 494/* or 498 */, 80, SEATTLE_CONFIG);
30002983
30012984   /* speedups */
30022985   mips3drc_add_hotspot(machine().device("maincpu"), 0x8015773C, 0x3C038025, 250);     /* confirmed */
r21058r21059
30072990DRIVER_INIT_MEMBER(seattle_state,carnevil)
30082991{
30092992   dcs2_init(machine(), 2, 0x0af7);
3010   init_common(machine(), MIDWAY_IOASIC_CARNEVIL, 469/* 469 or 486 or 528 */, 80, SEATTLE_CONFIG);
2993   init_common(MIDWAY_IOASIC_CARNEVIL, 469/* 469 or 486 or 528 */, 80, SEATTLE_CONFIG);
30112994
30122995   /* set up the gun */
30132996   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x16800000, 0x1680001f, read32_delegate(FUNC(seattle_state::carnevil_gun_r),this), write32_delegate(FUNC(seattle_state::carnevil_gun_w),this));
r21058r21059
30213004DRIVER_INIT_MEMBER(seattle_state,hyprdriv)
30223005{
30233006   dcs2_init(machine(), 2, 0x0af7);
3024   init_common(machine(), MIDWAY_IOASIC_HYPRDRIV, 469/* unknown */, 80, SEATTLE_WIDGET_CONFIG);
3007   init_common(MIDWAY_IOASIC_HYPRDRIV, 469/* unknown */, 80, SEATTLE_WIDGET_CONFIG);
30253008
30263009   /* speedups */
30273010   mips3drc_add_hotspot(machine().device("maincpu"), 0x801643BC, 0x3C03801B, 250);     /* confirmed */
trunk/src/mame/drivers/tmaster.c
r21058r21059
138138   UINT16 m_addr;
139139   UINT32 m_gfx_offs;
140140   UINT32 m_gfx_size;
141   int (*m_compute_addr) (UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high);
141   int (tmaster_state::*m_compute_addr) (UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high);
142142   UINT16 m_galgames_cart;
143143   UINT32 m_palette_offset;
144144   UINT8 m_palette_index;
r21058r21059
185185   DECLARE_VIDEO_START(galgames);
186186   UINT32 screen_update_tmaster(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
187187   TIMER_DEVICE_CALLBACK_MEMBER(tm3k_interrupt);
188   UINT8 binary_to_BCD(UINT8 data);
189   int tmaster_compute_addr(UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high);
190   int galgames_compute_addr(UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high);
191   void tmaster_draw();
192   void galgames_update_rombank(UINT32 cart);
188193};
189194
190195
r21058r21059
248253***************************************************************************/
249254
250255
251static UINT8 binary_to_BCD(UINT8 data)
256UINT8 tmaster_state::binary_to_BCD(UINT8 data)
252257{
253258   data %= 100;
254259
r21058r21059
328333
329334***************************************************************************/
330335
331static int tmaster_compute_addr(UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high)
336int tmaster_state::tmaster_compute_addr(UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high)
332337{
333338   return (reg_low & 0xff) | ((reg_mid & 0x1ff) << 8) | (reg_high << 17);
334339}
335340
336static int galgames_compute_addr(UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high)
341int tmaster_state::galgames_compute_addr(UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high)
337342{
338343   return reg_low | (reg_mid << 16);
339344}
r21058r21059
350355      }
351356   }
352357
353   m_compute_addr = tmaster_compute_addr;
358   m_compute_addr = &tmaster_state::tmaster_compute_addr;
354359}
355360
356361VIDEO_START_MEMBER(tmaster_state,galgames)
357362{
358363   VIDEO_START_CALL_MEMBER( tmaster );
359   m_compute_addr = galgames_compute_addr;
364   m_compute_addr = &tmaster_state::galgames_compute_addr;
360365}
361366
362367UINT32 tmaster_state::screen_update_tmaster(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r21058r21059
392397   COMBINE_DATA( &m_addr );
393398}
394399
395static void tmaster_draw(running_machine &machine)
400void tmaster_state::tmaster_draw()
396401{
397   tmaster_state *state = machine.driver_data<tmaster_state>();
398402   int x,y,x0,x1,y0,y1,dx,dy,flipx,flipy,sx,sy,sw,sh, addr, mode, layer,buffer, color;
399403
400   UINT8 *gfxdata  =   state->memregion( "blitter" )->base() + state->m_gfx_offs;
404   UINT8 *gfxdata  =   memregion( "blitter" )->base() + m_gfx_offs;
401405
402406   UINT16 pen;
403407
404   buffer  =   (state->m_regs[0x02/2] >> 8) & 3;   // 1 bit per layer, selects the currently displayed buffer
405   sw      =    state->m_regs[0x04/2];
406   sx      =    state->m_regs[0x06/2];
407   sh      =    state->m_regs[0x08/2] + 1;
408   sy      =    state->m_regs[0x0a/2];
409   addr    =   (*state->m_compute_addr)(
410               state->m_regs[0x0c/2],
411               state->m_regs[0x0e/2], state->m_addr);
412   mode    =    state->m_regs[0x10/2];
408   buffer  =   (m_regs[0x02/2] >> 8) & 3;   // 1 bit per layer, selects the currently displayed buffer
409   sw      =    m_regs[0x04/2];
410   sx      =    m_regs[0x06/2];
411   sh      =    m_regs[0x08/2] + 1;
412   sy      =    m_regs[0x0a/2];
413   addr    =   (this->*m_compute_addr)(
414               m_regs[0x0c/2],
415               m_regs[0x0e/2], m_addr);
416   mode    =    m_regs[0x10/2];
413417
414418   layer   =   (mode >> 7) & 1;    // layer to draw to
415419   buffer  =   ((mode >> 6) & 1) ^ ((buffer >> layer) & 1);    // bit 6 selects whether to use the opposite buffer to that displayed
416   bitmap_ind16 &bitmap    =   state->m_bitmap[layer][buffer];
420   bitmap_ind16 &bitmap    =   m_bitmap[layer][buffer];
417421
418422   addr <<= 1;
419423
420424#ifdef MAME_DEBUG
421425#if 0
422   logerror("%s: blit w %03x, h %02x, x %03x, y %02x, src %06x, fill/addr %04x, repl/color %04x, mode %02x\n", machine.describe_context(),
423         sw,sh,sx,sy, addr, state->m_addr, state->m_color, mode
426   logerror("%s: blit w %03x, h %02x, x %03x, y %02x, src %06x, fill/addr %04x, repl/color %04x, mode %02x\n", machine().describe_context(),
427         sw,sh,sx,sy, addr, m_addr, m_color, mode
424428   );
425429#endif
426430#endif
r21058r21059
437441   sx = (sx & 0x7fff) - (sx & 0x8000);
438442   sy = (sy & 0x7fff) - (sy & 0x8000);
439443
440   color = (state->m_color & 0x0f) << 8;
444   color = (m_color & 0x0f) << 8;
441445
442446   switch (mode & 0x20)
443447   {
444448      case 0x00:                          // blit with transparency
445         if (addr > state->m_gfx_size - sw*sh)
449         if (addr > m_gfx_size - sw*sh)
446450         {
447            logerror("%s: blit error, addr %06x out of bounds\n", machine.describe_context(),addr);
448            addr = state->m_gfx_size - sw*sh;
451            logerror("%s: blit error, addr %06x out of bounds\n", machine().describe_context(),addr);
452            addr = m_gfx_size - sw*sh;
449453         }
450454
451455         if ( mode & 0x200 )
452456         {
453457            // copy from ROM, replacing occurrences of src pen with dst pen
454458
455            UINT8 dst_pen = (state->m_color >> 8) & 0xff;
456            UINT8 src_pen = (state->m_color >> 0) & 0xff;
459            UINT8 dst_pen = (m_color >> 8) & 0xff;
460            UINT8 src_pen = (m_color >> 0) & 0xff;
457461
458462            for (y = y0; y != y1; y += dy)
459463            {
r21058r21059
487491         break;
488492
489493      case 0x20:                          // solid fill
490         pen = ((state->m_addr >> 8) & 0xff) + color;
494         pen = ((m_addr >> 8) & 0xff) + color;
491495
492496         if ((pen & 0xff) == 0xff)
493497            pen = 0xff;
r21058r21059
511515   switch (offset*2)
512516   {
513517      case 0x0e:
514         tmaster_draw(machine());
518         tmaster_draw();
515519         machine().device("maincpu")->execute().set_input_line(2, HOLD_LINE);
516520         break;
517521   }
r21058r21059
669673
670674// Carts (preliminary, PIC communication is not implemented)
671675
672static void galgames_update_rombank(running_machine &machine, UINT32 cart)
676void tmaster_state::galgames_update_rombank(UINT32 cart)
673677{
674   tmaster_state *state = machine.driver_data<tmaster_state>();
675   state->m_galgames_cart = cart;
678   m_galgames_cart = cart;
676679
677   state->m_gfx_offs = 0x200000 * cart;
680   m_gfx_offs = 0x200000 * cart;
678681
679   if (state->membank(GALGAMES_BANK_000000_R)->entry() == GALGAMES_RAM)
680      state->membank(GALGAMES_BANK_200000_R)->set_entry(GALGAMES_ROM0 + state->m_galgames_cart);  // rom
682   if (membank(GALGAMES_BANK_000000_R)->entry() == GALGAMES_RAM)
683      membank(GALGAMES_BANK_200000_R)->set_entry(GALGAMES_ROM0 + m_galgames_cart);  // rom
681684
682   state->membank(GALGAMES_BANK_240000_R)->set_entry(GALGAMES_ROM0 + state->m_galgames_cart);  // rom
685   membank(GALGAMES_BANK_240000_R)->set_entry(GALGAMES_ROM0 + m_galgames_cart);  // rom
683686}
684687
685688WRITE16_MEMBER(tmaster_state::galgames_cart_sel_w)
r21058r21059
703706         case 0x03:
704707         case 0x04:
705708            machine().device<eeprom_device>(galgames_eeprom_names[data & 0xff])->set_cs_line(CLEAR_LINE);
706            galgames_update_rombank(machine(), data & 0xff);
709            galgames_update_rombank(data & 0xff);
707710            break;
708711
709712         default:
710713            machine().device<eeprom_device>(galgames_eeprom_names[0])->set_cs_line(CLEAR_LINE);
711            galgames_update_rombank(machine(), 0);
714            galgames_update_rombank(0);
712715            logerror("%06x: unknown cart sel = %04x\n", space.device().safe_pc(), data);
713716            break;
714717      }
r21058r21059
730733      if ((data & 0xf7) == 0x05)
731734      {
732735         membank(GALGAMES_BANK_000000_R)->set_entry(GALGAMES_RAM);   // ram
733         galgames_update_rombank(machine(), m_galgames_cart);
736         galgames_update_rombank(m_galgames_cart);
734737         logerror("%06x: romram bank = %04x\n", space.device().safe_pc(), data);
735738      }
736739      else
r21058r21059
972975
973976   membank(GALGAMES_BANK_240000_R)->set_entry(GALGAMES_ROM0);  // rom
974977
975   galgames_update_rombank(machine(), 0);
978   galgames_update_rombank(0);
976979
977980   machine().device("maincpu")->reset();
978981}
trunk/src/mame/drivers/zn.c
r21058r21059
124124   DECLARE_MACHINE_RESET(coh1002v);
125125   DECLARE_MACHINE_RESET(coh1002m);
126126   INTERRUPT_GEN_MEMBER(qsound_interrupt);
127   inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ... );
128   inline UINT8 psxreadbyte( UINT32 *p_n_psxram, UINT32 n_address );
129   inline void psxwritebyte( UINT32 *p_n_psxram, UINT32 n_address, UINT8 n_data );
130   void zn_driver_init(  );
131   void atpsx_dma_read(UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size );
132   void atpsx_dma_write(UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size );
133   void jdredd_vblank(screen_device &screen, bool vblank_state);
127134};
128135
129INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... )
136inline void ATTR_PRINTF(3,4) zn_state::verboselog( int n_level, const char *s_fmt, ... )
130137{
131138   if( VERBOSE_LEVEL >= n_level )
132139   {
r21058r21059
135142      va_start( v, s_fmt );
136143      vsprintf( buf, s_fmt, v );
137144      va_end( v );
138      logerror( "%s: %s", machine.describe_context(), buf );
145      logerror( "%s: %s", machine().describe_context(), buf );
139146   }
140147}
141148
142149#ifdef UNUSED_FUNCTION
143INLINE UINT8 psxreadbyte( UINT32 *p_n_psxram, UINT32 n_address )
150inline UINT8 zn_state::psxreadbyte( UINT32 *p_n_psxram, UINT32 n_address )
144151{
145152   return *( (UINT8 *)p_n_psxram + BYTE4_XOR_LE( n_address ) );
146153}
147154#endif
148155
149INLINE void psxwritebyte( UINT32 *p_n_psxram, UINT32 n_address, UINT8 n_data )
156inline void zn_state::psxwritebyte( UINT32 *p_n_psxram, UINT32 n_address, UINT8 n_data )
150157{
151158   *( (UINT8 *)p_n_psxram + BYTE4_XOR_LE( n_address ) ) = n_data;
152159}
r21058r21059
312319
313320READ32_MEMBER(zn_state::znsecsel_r)
314321{
315   verboselog( machine(), 2, "znsecsel_r( %08x, %08x )\n", offset, mem_mask );
322   verboselog(2, "znsecsel_r( %08x, %08x )\n", offset, mem_mask );
316323   return m_n_znsecsel;
317324}
318325
r21058r21059
324331   m_znsec1->select( ( m_n_znsecsel >> 3 ) & 1 );
325332   m_zndip->select( ( m_n_znsecsel & 0x8c ) != 0x8c );
326333
327   verboselog( machine(), 2, "znsecsel_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
334   verboselog(2, "znsecsel_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
328335}
329336
330337READ32_MEMBER(zn_state::boardconfig_r)
r21058r21059
360367
361368READ32_MEMBER(zn_state::unknown_r)
362369{
363   verboselog( machine(), 0, "unknown_r( %08x, %08x )\n", offset, mem_mask );
370   verboselog(0, "unknown_r( %08x, %08x )\n", offset, mem_mask );
364371   return 0xffffffff;
365372}
366373
r21058r21059
374381   */
375382   if( ( data & ~0x23 ) != 0 )
376383   {
377      verboselog( machine(), 0, "coin_w %08x\n", data );
384      verboselog(0, "coin_w %08x\n", data );
378385   }
379386}
380387
r21058r21059
406413static ADDRESS_MAP_START( link_map, AS_PROGRAM, 8, zn_state )
407414ADDRESS_MAP_END
408415
409static void zn_driver_init( running_machine &machine )
416void zn_state::zn_driver_init(  )
410417{
411   zn_state *state = machine.driver_data<zn_state>();
412418   int n_game;
413419
414420   n_game = 0;
415421   while( zn_config_table[ n_game ].s_name != NULL )
416422   {
417      if( strcmp( machine.system().name, zn_config_table[ n_game ].s_name ) == 0 )
423      if( strcmp( machine().system().name, zn_config_table[ n_game ].s_name ) == 0 )
418424      {
419         state->m_znsec0->init( zn_config_table[ n_game ].p_n_mainsec );
420         state->m_znsec1->init( zn_config_table[ n_game ].p_n_gamesec );
425         m_znsec0->init( zn_config_table[ n_game ].p_n_mainsec );
426         m_znsec1->init( zn_config_table[ n_game ].p_n_gamesec );
421427//          psx_sio_install_handler( machine, 0, sio_pad_handler );
422428         break;
423429      }
r21058r21059
591597READ32_MEMBER(zn_state::capcom_kickharness_r)
592598{
593599   /* required for buttons 4,5&6 */
594   verboselog( machine(), 2, "capcom_kickharness_r( %08x, %08x )\n", offset, mem_mask );
600   verboselog(2, "capcom_kickharness_r( %08x, %08x )\n", offset, mem_mask );
595601   return 0xffffffff;
596602}
597603
r21058r21059
626632   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank ( 0x1fb80000, 0x1fbfffff, "bank3" );     /* country rom */
627633   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fb60000, 0x1fb60003, write32_delegate(FUNC(zn_state::zn_qsound_w),this));
628634
629   zn_driver_init(machine());
635   zn_driver_init();
630636
631637   if( strcmp( machine().system().name, "glpracr" ) == 0 ||
632638      strcmp( machine().system().name, "glpracr2l" ) == 0 )
r21058r21059
842848   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank ( 0x1fb80000, 0x1fbfffff, "bank3" );     /* country rom */
843849   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fb60000, 0x1fb60003, write32_delegate(FUNC(zn_state::zn_qsound_w),this));
844850
845   zn_driver_init(machine());
851   zn_driver_init();
846852}
847853
848854MACHINE_RESET_MEMBER(zn_state,coh3002c)
r21058r21059
10881094{
10891095   device_t *mb3773 = machine().device("mb3773");
10901096   mb3773_set_ck(mb3773, (data & 0x20) >> 5);
1091   verboselog( machine(), 1, "bank_coh1000t_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
1097   verboselog(1, "bank_coh1000t_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
10921098   membank( "bank1" )->set_base( memregion( "user2" )->base() + ( ( data & 3 ) * 0x800000 ) );
10931099}
10941100
r21058r21059
11271133   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x1fb80000, 0x1fb80003, read32_delegate(FUNC(zn_state::taitofx1a_ymsound_r),this), write32_delegate(FUNC(zn_state::taitofx1a_ymsound_w),this));
11281134   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank( 0x1fbe0000, 0x1fbe0000 + ( m_taitofx1_eeprom_size1 - 1 ), "bank2" );
11291135
1130   zn_driver_init(machine());
1136   zn_driver_init();
11311137}
11321138
11331139MACHINE_RESET_MEMBER(zn_state,coh1000ta)
r21058r21059
11861192
11871193WRITE32_MEMBER(zn_state::taitofx1b_volume_w)
11881194{
1189   verboselog( machine(), 1, "taitofx1_volume_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
1195   verboselog(1, "taitofx1_volume_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
11901196}
11911197
11921198WRITE32_MEMBER(zn_state::taitofx1b_sound_w)
11931199{
1194   verboselog( machine(), 1, "taitofx1_sound_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
1200   verboselog(1, "taitofx1_sound_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
11951201}
11961202
11971203READ32_MEMBER(zn_state::taitofx1b_sound_r)
11981204{
11991205   UINT32 data = 0; // bit 0 = busy?
1200   verboselog( machine(), 1, "taitofx1_sound_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
1206   verboselog(1, "taitofx1_sound_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
12011207   return data;
12021208}
12031209
r21058r21059
12171223   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler     ( 0x1fbc0000, 0x1fbc0003, read32_delegate(FUNC(zn_state::taitofx1b_sound_r),this));
12181224   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank( 0x1fbe0000, 0x1fbe0000 + ( m_taitofx1_eeprom_size2 - 1 ), "bank3" );
12191225
1220   zn_driver_init(machine());
1226   zn_driver_init();
12211227}
12221228
12231229MACHINE_RESET_MEMBER(zn_state,coh1000tb)
r21058r21059
13541360      *2                  - Unpopulated DIP28 socket
13551361*/
13561362
1357static void atpsx_dma_read( zn_state *state, UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size )
1363void zn_state::atpsx_dma_read( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size )
13581364{
1359   device_t *ide = state->machine().device("ide");
1365   device_t *ide = machine().device("ide");
13601366
13611367   logerror("DMA read: %d bytes (%d words) to %08x\n", n_size<<2, n_size, n_address);
13621368
r21058r21059
13691375
13701376   /* dma size is in 32-bit words, convert to bytes */
13711377   n_size <<= 2;
1372   address_space &space = state->machine().firstcpu->space(AS_PROGRAM);
1378   address_space &space = machine().firstcpu->space(AS_PROGRAM);
13731379   while( n_size > 0 )
13741380   {
13751381      psxwritebyte( p_n_psxram, n_address, ide_controller32_r( ide, space, 0x1f0 / 4, 0x000000ff ) );
r21058r21059
13781384   }
13791385}
13801386
1381static void atpsx_dma_write( zn_state *state, UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size )
1387void zn_state::atpsx_dma_write( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size )
13821388{
13831389   logerror("DMA write from %08x for %d bytes\n", n_address, n_size<<2);
13841390}
r21058r21059
13931399   machine().device("maincpu")->memory().space(AS_PROGRAM).nop_readwrite                     ( 0x1f7e8000, 0x1f7e8003);
13941400   machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler( *ide, 0x1f7f4000, 0x1f7f4fff, FUNC(ide_controller32_r), FUNC(ide_controller32_w) );
13951401
1396   zn_driver_init(machine());
1402   zn_driver_init();
13971403}
13981404
13991405MACHINE_RESET_MEMBER(zn_state,coh1000w)
r21058r21059
14081414
14091415   MCFG_IDE_CONTROLLER_ADD("ide", ide_devices, "hdd", NULL, true)
14101416   MCFG_IDE_CONTROLLER_IRQ_HANDLER(DEVWRITELINE("maincpu:irq", psxirq_device, intin10))
1411   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 5, psx_dma_read_delegate( FUNC( atpsx_dma_read ), (zn_state *) owner ) )
1412   MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 5, psx_dma_write_delegate( FUNC( atpsx_dma_write ), (zn_state *) owner ) )
1417   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 5, psx_dma_read_delegate( FUNC( zn_state::atpsx_dma_read ), (zn_state *) owner ) )
1418   MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 5, psx_dma_write_delegate( FUNC( zn_state::atpsx_dma_write ), (zn_state *) owner ) )
14131419MACHINE_CONFIG_END
14141420
14151421/*
r21058r21059
15801586   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fa10300, 0x1fa10303, write32_delegate(FUNC(zn_state::coh1002e_bank_w),this));
15811587   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fb00000, 0x1fb00007, write32_delegate(FUNC(zn_state::coh1002e_latch_w),this));
15821588
1583   zn_driver_init(machine());
1589   zn_driver_init();
15841590}
15851591
15861592MACHINE_RESET_MEMBER(zn_state,coh1002e)
r21058r21059
17221728   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fa10300, 0x1fa10303, write32_delegate(FUNC(zn_state::bam2_sec_w),this));
17231729   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fb00000, 0x1fb00007, write32_delegate(FUNC(zn_state::bam2_mcu_w),this));
17241730
1725   zn_driver_init(machine());
1731   zn_driver_init();
17261732}
17271733
17281734MACHINE_RESET_MEMBER(zn_state,bam2)
r21058r21059
19631969   return m_jdredd_gun_mux;
19641970}
19651971
1966void jdredd_vblank(zn_state *state, screen_device &screen, bool vblank_state)
1972void zn_state::jdredd_vblank(screen_device &screen, bool vblank_state)
19671973{
19681974   int x;
19691975   int y;
19701976
19711977   if( vblank_state )
19721978   {
1973      state->m_jdredd_gun_mux = !state->m_jdredd_gun_mux;
1979      m_jdredd_gun_mux = !m_jdredd_gun_mux;
19741980
1975      if( state->m_jdredd_gun_mux == 0 )
1981      if( m_jdredd_gun_mux == 0 )
19761982      {
1977         x = state->ioport("GUN1X")->read();
1978         y = state->ioport("GUN1Y")->read();
1983         x = ioport("GUN1X")->read();
1984         y = ioport("GUN1Y")->read();
19791985      }
19801986      else
19811987      {
1982         x = state->ioport("GUN2X")->read();
1983         y = state->ioport("GUN2Y")->read();
1988         x = ioport("GUN2X")->read();
1989         y = ioport("GUN2Y")->read();
19841990      }
19851991
19861992      if( x > 0x393 && x < 0xcb2 &&
19871993         y > 0x02d && y < 0x217 )
19881994      {
1989         state->m_gpu->lightgun_set( x, y );
1995         m_gpu->lightgun_set( x, y );
19901996      }
19911997   }
19921998}
19931999
19942000WRITE32_MEMBER(zn_state::acpsx_00_w)
19952001{
1996   verboselog( machine(), 0, "acpsx_00_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
2002   verboselog(0, "acpsx_00_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
19972003}
19982004
19992005WRITE32_MEMBER(zn_state::acpsx_10_w)
20002006{
2001   verboselog( machine(), 0, "acpsx_10_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
2007   verboselog(0, "acpsx_10_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
20022008}
20032009
20042010WRITE32_MEMBER(zn_state::nbajamex_80_w)
20052011{
2006   verboselog( machine(), 0, "nbajamex_80_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
2012   verboselog(0, "nbajamex_80_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
20072013   psxirq_device *psxirq = (psxirq_device *) machine().device("maincpu:irq");
20082014   psxirq->intin10(1);
20092015}
r21058r21059
20112017READ32_MEMBER(zn_state::nbajamex_08_r)
20122018{
20132019   UINT32 data = 0xffffffff;
2014   verboselog( machine(), 0, "nbajamex_08_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
2020   verboselog(0, "nbajamex_08_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
20152021   return data;
20162022}
20172023
20182024READ32_MEMBER(zn_state::nbajamex_80_r)
20192025{
20202026   UINT32 data = 0xffffffff;
2021   verboselog( machine(), 0, "nbajamex_80_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
2027   verboselog(0, "nbajamex_80_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
20222028   return data;
20232029}
20242030
r21058r21059
20482054      machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x1fbfff90, 0x1fbfff9f, read32_delegate(FUNC(zn_state::jdredd_ide_r),this), write32_delegate(FUNC(zn_state::jdredd_ide_w),this) );
20492055   }
20502056
2051   zn_driver_init(machine());
2057   zn_driver_init();
20522058}
20532059
20542060MACHINE_RESET_MEMBER(zn_state,coh1000a)
r21058r21059
20692075static MACHINE_CONFIG_DERIVED( coh1000a_ide, zn1_2mb_vram )
20702076
20712077   MCFG_DEVICE_MODIFY( "gpu" )
2072   MCFG_PSXGPU_VBLANK_CALLBACK( vblank_state_delegate( FUNC( jdredd_vblank ), (zn_state *) owner ) )
2078   MCFG_PSXGPU_VBLANK_CALLBACK( vblank_state_delegate( FUNC( zn_state::jdredd_vblank ), (zn_state *) owner ) )
20732079
20742080   MCFG_MACHINE_RESET_OVERRIDE(zn_state, coh1000a )
20752081
r21058r21059
22032209   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank ( 0x1f000000, 0x1f7fffff, "bank1" ); /* banked rom */
22042210   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fb00000, 0x1fb00003, write32_delegate(FUNC(zn_state::coh1001l_bnk_w),this) );
22052211
2206   zn_driver_init(machine());
2212   zn_driver_init();
22072213}
22082214
22092215MACHINE_RESET_MEMBER(zn_state,coh1001l)
r21058r21059
22452251   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank ( 0x1fb00000, 0x1fbfffff, "bank2" );
22462252   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler( 0x1fb00000, 0x1fb00003, write32_delegate(FUNC(zn_state::coh1002v_bnk_w),this));
22472253
2248   zn_driver_init(machine());
2254   zn_driver_init();
22492255}
22502256
22512257MACHINE_RESET_MEMBER(zn_state,coh1002v)
r21058r21059
24182424
24192425WRITE32_MEMBER(zn_state::coh1002m_bank_w)
24202426{
2421   verboselog( machine(), 1, "coh1002m_bank_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
2427   verboselog(1, "coh1002m_bank_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
24222428   membank( "bank1" )->set_base( memregion( "user2" )->base() + ((data>>16) * 0x800000) );
24232429}
24242430
r21058r21059
24472453   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x1fb00000, 0x1fb00003, read32_delegate(FUNC(zn_state::cbaj_z80_r),this), write32_delegate(FUNC(zn_state::cbaj_z80_w),this));
24482454   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler    ( 0x1fb00004, 0x1fb00007, write32_delegate(FUNC(zn_state::coh1002m_bank_w),this));
24492455
2450   zn_driver_init(machine());
2456   zn_driver_init();
24512457}
24522458
24532459MACHINE_RESET_MEMBER(zn_state,coh1002m)
trunk/src/mame/drivers/viper.c
r21058r21059
351351   INTERRUPT_GEN_MEMBER(viper_vblank);
352352   TIMER_CALLBACK_MEMBER(epic_global_timer_callback);
353353   TIMER_CALLBACK_MEMBER(ds2430_timer_callback);
354   const char* epic_get_register_name(UINT32 reg);
355   void epic_update_interrupts();
356   void mpc8240_interrupt(int irq);
357   void mpc8240_epic_init();
358   void mpc8240_epic_reset(void);
359   int ds2430_insert_cmd_bit(int bit);
360   void DS2430_w(int bit);
354361};
355362
356363UINT32 viper_state::screen_update_viper(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
r21058r21059
454461/*****************************************************************************/
455462// MPC8240 Embedded Programmable Interrupt Controller (EPIC)
456463
457static void mpc8240_interrupt(running_machine &machine, int irq);
458
459464#define MPC8240_IRQ0                0
460465#define MPC8240_IRQ1                1
461466#define MPC8240_IRQ2                2
r21058r21059
530535static MPC8240_EPIC epic;
531536
532537#if VIPER_DEBUG_EPIC_REGS
533static const char* epic_get_register_name(UINT32 reg)
538const viper_state::char* epic_get_register_name(UINT32 reg)
534539{
535540   switch (reg >> 16)
536541   {
r21058r21059
663668      epic.global_timer[timer_num].timer->reset();
664669   }
665670
666   mpc8240_interrupt(machine(), MPC8240_GTIMER0_IRQ + timer_num);
671   mpc8240_interrupt(MPC8240_GTIMER0_IRQ + timer_num);
667672}
668673
669674
670static void epic_update_interrupts(running_machine &machine)
675void viper_state::epic_update_interrupts()
671676{
672677   int i;
673678
r21058r21059
709714         printf("vector = %02X\n", epic.iack);
710715#endif
711716
712      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE);
717      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE);
713718   }
714719   else
715720   {
716      machine.device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
721      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
717722   }
718723}
719724
r21058r21059
783788                     if (epic.i2c_cr & 0x40)
784789                     {
785790                        printf("I2C interrupt\n");
786                        mpc8240_interrupt(machine(), MPC8240_I2C_IRQ);
791                        mpc8240_interrupt(MPC8240_I2C_IRQ);
787792
788793                        // set interrupt flag in status register
789794                        epic.i2c_sr |= 0x2;
r21058r21059
802807                     /*if (epic.i2c_cr & 0x40)
803808                     {
804809                         printf("I2C interrupt\n");
805                         mpc8240_interrupt(machine, MPC8240_I2C_IRQ);
810                         mpc8240_interrupt(MPC8240_I2C_IRQ);
806811
807812                         // set interrupt flag in status register
808813                         epic.i2c_sr |= 0x2;
r21058r21059
886891         {
887892            case 0x00a0:            // Offset 0x600A0 - IACK
888893            {
889               epic_update_interrupts(machine());
894               epic_update_interrupts();
890895
891896               if (epic.active_irq >= 0)
892897               {
r21058r21059
988993#if VIPER_DEBUG_EPIC_I2C
989994                        printf("I2C interrupt\n");
990995#endif
991                        mpc8240_interrupt(machine(), MPC8240_I2C_IRQ);
996                        mpc8240_interrupt(MPC8240_I2C_IRQ);
992997
993998                        // set interrupt flag in status register
994999                        epic.i2c_sr |= 0x2;
r21058r21059
10101015#if VIPER_DEBUG_EPIC_I2C
10111016                        printf("I2C interrupt\n");
10121017#endif
1013                        mpc8240_interrupt(machine(), MPC8240_I2C_IRQ);
1018                        mpc8240_interrupt(MPC8240_I2C_IRQ);
10141019
10151020                        // set interrupt flag in status register
10161021                        epic.i2c_sr |= 0x2;
r21058r21059
10511056               epic.irq[MPC8240_GTIMER0_IRQ + timer_num].priority = (data >> 16) & 0xf;
10521057               epic.irq[MPC8240_GTIMER0_IRQ + timer_num].vector = data & 0xff;
10531058
1054               epic_update_interrupts(machine());
1059               epic_update_interrupts();
10551060               break;
10561061            }
10571062            case 0x1130:            // Offset 0x41130 - Global timer 0 destination register
r21058r21059
10631068
10641069               epic.irq[MPC8240_GTIMER0_IRQ + timer_num].destination = data & 0x1;
10651070
1066               epic_update_interrupts(machine());
1071               epic_update_interrupts();
10671072               break;
10681073            }
10691074            case 0x1110:            // Offset 0x41110 - Global timer 0 base count register
r21058r21059
11231128               epic.irq[MPC8240_IRQ0 + irq].priority = (data >> 16) & 0xf;
11241129               epic.irq[MPC8240_IRQ0 + irq].vector = data & 0xff;
11251130
1126               epic_update_interrupts(machine());
1131               epic_update_interrupts();
11271132               break;
11281133            }
11291134            case 0x1020:            // Offset 0x51020 - I2C IRQ vector/priority register
r21058r21059
11321137               epic.irq[MPC8240_I2C_IRQ].priority = (data >> 16) & 0xf;
11331138               epic.irq[MPC8240_I2C_IRQ].vector = data & 0xff;
11341139
1135               epic_update_interrupts(machine());
1140               epic_update_interrupts();
11361141               break;
11371142            }
11381143            case 0x0210:            // Offset 0x50210 - IRQ0 destination register
r21058r21059
11561161
11571162               epic.irq[MPC8240_IRQ0 + irq].destination = data & 0x1;
11581163
1159               epic_update_interrupts(machine());
1164               epic_update_interrupts();
11601165               break;
11611166            }
11621167            case 0x1030:            // Offset 0x51030 - I2C IRQ destination register
11631168            {
11641169               epic.irq[MPC8240_I2C_IRQ].destination = data & 0x1;
1165               epic_update_interrupts(machine());
1170               epic_update_interrupts();
11661171               break;
11671172            }
11681173         }
r21058r21059
11821187               epic.irq[epic.active_irq].active = 0;
11831188               epic.active_irq = -1;
11841189
1185               epic_update_interrupts(machine());
1190               epic_update_interrupts();
11861191               break;
11871192         }
11881193         break;
r21058r21059
12001205}
12011206*/
12021207
1203static void mpc8240_interrupt(running_machine &machine, int irq)
1208void viper_state::mpc8240_interrupt(int irq)
12041209{
12051210   epic.irq[irq].pending = 1;
1206   epic_update_interrupts(machine);
1211   epic_update_interrupts();
12071212}
12081213
1209static void mpc8240_epic_init(running_machine &machine)
1214void viper_state::mpc8240_epic_init()
12101215{
1211   viper_state *state = machine.driver_data<viper_state>();
1212   epic.global_timer[0].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
1213   epic.global_timer[1].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
1214   epic.global_timer[2].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
1215   epic.global_timer[3].timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),state));
1216   epic.global_timer[0].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),this));
1217   epic.global_timer[1].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),this));
1218   epic.global_timer[2].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),this));
1219   epic.global_timer[3].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::epic_global_timer_callback),this));
12161220}
12171221
1218static void mpc8240_epic_reset(void)
1222void viper_state::mpc8240_epic_reset(void)
12191223{
12201224   int i;
12211225
r21058r21059
17061710}
17071711
17081712
1709static int ds2430_insert_cmd_bit(int bit)
1713int viper_state::ds2430_insert_cmd_bit(int bit)
17101714{
17111715   ds2430_data <<= 1;
17121716   ds2430_data |= bit & 1;
r21058r21059
17221726   return 0;
17231727}
17241728
1725static void DS2430_w(int bit)
1729void viper_state::DS2430_w(int bit)
17261730{
17271731   switch (ds2430_state)
17281732   {
r21058r21059
19861990
19871991INTERRUPT_GEN_MEMBER(viper_state::viper_vblank)
19881992{
1989   mpc8240_interrupt(machine(), MPC8240_IRQ0);
1993   mpc8240_interrupt(MPC8240_IRQ0);
19901994   //mpc8240_interrupt(device.machine, MPC8240_IRQ3);
19911995}
19921996
19931997static void voodoo_vblank(device_t *device, int state)
19941998{
1995   mpc8240_interrupt(device->machine(), MPC8240_IRQ4);
1999   viper_state *drvstate = device->machine().driver_data<viper_state>();
2000   drvstate->mpc8240_interrupt(MPC8240_IRQ4);
19962001}
19972002
19982003void viper_state::machine_start()
19992004{
20002005   ds2430_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(viper_state::ds2430_timer_callback),this));
20012006   ds2430_bit_timer = machine().device<timer_device>("ds2430_timer2");
2002   mpc8240_epic_init(machine());
2007   mpc8240_epic_init();
20032008
20042009   /* set conservative DRC options */
20052010   ppcdrc_set_options(machine().device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS);
trunk/src/mame/drivers/namcos12.c
r21058r21059
10961096   DECLARE_DRIVER_INIT(ghlpanic);
10971097   DECLARE_DRIVER_INIT(ptblank2);
10981098   DECLARE_MACHINE_RESET(namcos12);
1099   inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ... );
1100   void namcos12_rom_read( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size );
1101   void namcos12_sub_irq( screen_device &screen, bool vblank_state );
1102   void system11gun_install(  );
10991103};
11001104
1101INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... )
1105inline void ATTR_PRINTF(3,4) namcos12_state::verboselog( int n_level, const char *s_fmt, ... )
11021106{
11031107   if( VERBOSE_LEVEL >= n_level )
11041108   {
r21058r21059
11071111      va_start( v, s_fmt );
11081112      vsprintf( buf, s_fmt, v );
11091113      va_end( v );
1110      logerror( "%s: %s", machine.describe_context(), buf );
1114      logerror( "%s: %s", machine().describe_context(), buf );
11111115   }
11121116}
11131117
11141118WRITE32_MEMBER(namcos12_state::sharedram_w)
11151119{
1116   verboselog( machine(), 1, "sharedram_w( %08x, %08x, %08x )\n", ( offset * 4 ), data, mem_mask );
1120   verboselog(1, "sharedram_w( %08x, %08x, %08x )\n", ( offset * 4 ), data, mem_mask );
11171121   COMBINE_DATA( &m_sharedram[ offset ] );
11181122}
11191123
11201124READ32_MEMBER(namcos12_state::sharedram_r)
11211125{
1122   verboselog( machine(), 1, "sharedram_r( %08x, %08x ) %08x\n", ( offset * 4 ), mem_mask, m_sharedram[ offset ] );
1126   verboselog(1, "sharedram_r( %08x, %08x ) %08x\n", ( offset * 4 ), mem_mask, m_sharedram[ offset ] );
11231127   return m_sharedram[ offset ];
11241128}
11251129
r21058r21059
11591163
11601164   membank( "bank1" )->set_entry( m_n_bankoffset );
11611165
1162   verboselog( machine(), 1, "bankoffset_w( %08x, %08x, %08x ) %08x\n", offset, data, mem_mask, m_n_bankoffset );
1166   verboselog(1, "bankoffset_w( %08x, %08x, %08x ) %08x\n", offset, data, mem_mask, m_n_bankoffset );
11631167}
11641168
11651169WRITE32_MEMBER(namcos12_state::dmaoffset_w)
r21058r21059
11721176   {
11731177      m_n_dmaoffset = ( ( offset * 4 ) + 2 ) | ( data & 0xffff0000 );
11741178   }
1175   verboselog( machine(), 1, "dmaoffset_w( %08x, %08x, %08x ) %08x\n", offset, data, mem_mask, m_n_dmaoffset );
1179   verboselog(1, "dmaoffset_w( %08x, %08x, %08x ) %08x\n", offset, data, mem_mask, m_n_dmaoffset );
11761180}
11771181
1178static void namcos12_rom_read( namcos12_state *state, UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size )
1182void namcos12_state::namcos12_rom_read( UINT32 *p_n_psxram, UINT32 n_address, INT32 n_size )
11791183{
11801184   const char *n_region;
11811185   int n_offset;
r21058r21059
11871191   INT32 n_ramleft;
11881192
11891193   // TODO: the check for going past the end of ram should be in dma.c
1190   UINT32 m_n_psxramsize = state->memshare("share1")->bytes();
1194   UINT32 m_n_psxramsize = memshare("share1")->bytes();
11911195
1192   if(state->m_has_tektagt_dma && !state->m_n_dmaoffset)
1196   if(m_has_tektagt_dma && !m_n_dmaoffset)
11931197   {
11941198      n_region = "user2";
1195      n_offset = state->m_n_tektagdmaoffset & 0x7fffffff;
1196      verboselog( state->machine(), 1, "namcos12_rom_read( %08x, %08x ) tektagt %08x\n", n_address, n_size, n_offset );
1199      n_offset = m_n_tektagdmaoffset & 0x7fffffff;
1200      verboselog(1, "namcos12_rom_read( %08x, %08x ) tektagt %08x\n", n_address, n_size, n_offset );
11971201   }
1198   else if( ( state->m_n_dmaoffset >= 0x80000000 ) || ( state->m_n_dmabias == 0x1f300000 ) )
1202   else if( ( m_n_dmaoffset >= 0x80000000 ) || ( m_n_dmabias == 0x1f300000 ) )
11991203   {
12001204      n_region = "user1";
1201      n_offset = state->m_n_dmaoffset & 0x003fffff;
1202      verboselog( state->machine(), 1, "namcos12_rom_read( %08x, %08x ) boot %08x\n", n_address, n_size, n_offset );
1205      n_offset = m_n_dmaoffset & 0x003fffff;
1206      verboselog(1, "namcos12_rom_read( %08x, %08x ) boot %08x\n", n_address, n_size, n_offset );
12031207   }
12041208   else
12051209   {
12061210      n_region = "user2";
1207      n_offset = state->m_n_dmaoffset & 0x7fffffff;
1208      verboselog( state->machine(), 1, "namcos12_rom_read( %08x, %08x ) game %08x\n", n_address, n_size, n_offset );
1211      n_offset = m_n_dmaoffset & 0x7fffffff;
1212      verboselog(1, "namcos12_rom_read( %08x, %08x ) game %08x\n", n_address, n_size, n_offset );
12091213   }
12101214
1211   source = (UINT16 *) state->memregion( n_region )->base();
1212   n_romleft = ( state->memregion( n_region )->bytes() - n_offset ) / 4;
1215   source = (UINT16 *) memregion( n_region )->base();
1216   n_romleft = ( memregion( n_region )->bytes() - n_offset ) / 4;
12131217   if( n_size > n_romleft )
12141218   {
1215      verboselog( state->machine(), 1, "namcos12_rom_read dma truncated %d to %d passed end of rom\n", n_size, n_romleft );
1219      verboselog(1, "namcos12_rom_read dma truncated %d to %d passed end of rom\n", n_size, n_romleft );
12161220      n_size = n_romleft;
12171221   }
12181222
r21058r21059
12211225   n_ramleft = ( m_n_psxramsize - n_address ) / 4;
12221226   if( n_size > n_ramleft )
12231227   {
1224      verboselog( state->machine(), 1, "namcos12_rom_read dma truncated %d to %d passed end of ram\n", n_size, n_ramleft );
1228      verboselog(1, "namcos12_rom_read dma truncated %d to %d passed end of ram\n", n_size, n_ramleft );
12251229      n_size = n_ramleft;
12261230   }
12271231
r21058r21059
12381242   }
12391243}
12401244
1241static void namcos12_sub_irq( namcos12_state *state, screen_device &screen, bool vblank_state )
1245void namcos12_state::namcos12_sub_irq( screen_device &screen, bool vblank_state )
12421246{
1243   irq1_line_pulse( state->machine().device( "sub" ) );
1247   irq1_line_pulse( *machine().device( "sub" ) );
12441248}
12451249
12461250WRITE32_MEMBER(namcos12_state::s12_dma_bias_w)
r21058r21059
12791283      output_set_value("P2_Start_lamp", (~data & 0x04)>>2);
12801284
12811285
1282      verboselog( machine(), 1, "system11gun_w: outputs (%08x %08x)\n", data, mem_mask );
1286      verboselog(1, "system11gun_w: outputs (%08x %08x)\n", data, mem_mask );
12831287   }
12841288   if( ACCESSING_BITS_16_31 )
12851289   {
1286      verboselog( machine(), 2, "system11gun_w: start reading (%08x %08x)\n", data, mem_mask );
1290      verboselog(2, "system11gun_w: start reading (%08x %08x)\n", data, mem_mask );
12871291   }
12881292}
12891293
r21058r21059
13051309      data = ( ioport("LIGHT1_Y")->read() ) | ( ( ioport("LIGHT1_Y")->read() + 1 ) << 16 );
13061310      break;
13071311   }
1308   verboselog( machine(), 2, "system11gun_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
1312   verboselog(2, "system11gun_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
13091313   return data;
13101314}
13111315
1312static void system11gun_install( running_machine &machine )
1316void namcos12_state::system11gun_install(  )
13131317{
1314   namcos12_state *state = machine.driver_data<namcos12_state>();
1315   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1f788000, 0x1f788003, write32_delegate(FUNC(namcos12_state::system11gun_w),state));
1316   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler (0x1f780000, 0x1f78000f, read32_delegate(FUNC(namcos12_state::system11gun_r),state));
1318   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1f788000, 0x1f788003, write32_delegate(FUNC(namcos12_state::system11gun_w),this));
1319   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler (0x1f780000, 0x1f78000f, read32_delegate(FUNC(namcos12_state::system11gun_r),this));
13171320}
13181321
13191322WRITE32_MEMBER(namcos12_state::kcoff_w)
r21058r21059
16061609   /* patch out wait for dma 5 to complete */
16071610   *( (UINT32 *)( memregion( "user1" )->base() + 0x331c4 ) ) = 0;
16081611
1609   system11gun_install(machine());
1612   system11gun_install();
16101613}
16111614
16121615DRIVER_INIT_MEMBER(namcos12_state,ghlpanic)
16131616{
16141617   DRIVER_INIT_CALL(namcos12);
16151618
1616   system11gun_install(machine());
1619   system11gun_install();
16171620}
16181621
16191622static MACHINE_CONFIG_START( coh700, namcos12_state )
r21058r21059
16211624   MCFG_CPU_ADD( "maincpu", CXD8661R, XTAL_100MHz )
16221625   MCFG_CPU_PROGRAM_MAP( namcos12_map)
16231626
1624   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 5, psx_dma_read_delegate( FUNC( namcos12_rom_read ), (namcos12_state *) owner ) )
1627   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 5, psx_dma_read_delegate( FUNC( namcos12_state::namcos12_rom_read ), (namcos12_state *) owner ) )
16251628
16261629   MCFG_CPU_ADD("sub", H83002, 16737350 )
16271630   MCFG_CPU_PROGRAM_MAP( s12h8rwmap)
r21058r21059
16331636
16341637   /* video hardware */
16351638   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8654Q, 0x200000, XTAL_53_693175MHz )
1636   MCFG_PSXGPU_VBLANK_CALLBACK( vblank_state_delegate( FUNC( namcos12_sub_irq ), (namcos12_state *) owner ) )
1639   MCFG_PSXGPU_VBLANK_CALLBACK( vblank_state_delegate( FUNC( namcos12_state::namcos12_sub_irq ), (namcos12_state *) owner ) )
16371640
16381641   /* sound hardware */
16391642   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
trunk/src/mame/drivers/ksys573.c
r21058r21059
557557   int m_atapi_xfermod;
558558
559559   UINT32 m_n_security_control;
560   void (*m_security_callback)( running_machine &machine, int data );
560   void (ksys573_state::*m_security_callback)( int data );
561561
562562   UINT8 m_gx700pwbf_output_data[ 4 ];
563   void (*m_gx700pwfbf_output_callback)( running_machine &machine, int offset, int data );
563   void (ksys573_state::*m_gx700pwfbf_output_callback)( int offset, int data );
564564   UINT16 m_gx894pwbba_output_data[ 8 ];
565   void (*m_gx894pwbba_output_callback)( running_machine &machine, int offset, int data );
565   void (ksys573_state::*m_gx894pwbba_output_callback)( int offset, int data );
566566
567567   UINT32 m_stage_mask;
568568   struct
r21058r21059
645645   DECLARE_DRIVER_INIT(konami573);
646646   DECLARE_MACHINE_RESET(konami573);
647647   TIMER_CALLBACK_MEMBER(atapi_xfer_end);
648   inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ... );
649   void atapi_init();
650   void cdrom_dma_read( UINT32 *ram, UINT32 n_address, INT32 n_size );
651   void cdrom_dma_write( UINT32 *ram, UINT32 n_address, INT32 n_size );
652   void flash_init(  );
653   void update_mode(  );
654   void sys573_vblank(screen_device &screen, bool vblank_state);
655   void gx700pwbf_output( int offset, UINT8 data );
656   void gx700pwfbf_init( void (ksys573_state::*output_callback_func)( int offset, int data ) );
657   void gn845pwbb_do_w( int offset, int data );
658   void gn845pwbb_clk_w( int offset, int data );
659   void gn845pwbb_output_callback( int offset, int data );
660   char *binary( char *s, UINT32 data );
661   void gx894pwbba_output( int offset, UINT8 data );
662   void gx894pwbba_init( void (ksys573_state::*output_callback_func)( int offset, int data ) );
663   void ddrsolo_output_callback( int offset, int data );
664   void drmn_output_callback( int offset, int data );
665   void dmx_output_callback( int offset, int data );
666   void salarymc_lamp_callback( int data );
667   void hyperbbc_lamp_callback( int data );
668   void mamboagg_output_callback( int offset, int data );
669   void punchmania_output_callback( int offset, int data );
648670};
649671
650INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... )
672void ATTR_PRINTF(3,4) ksys573_state::verboselog( int n_level, const char *s_fmt, ... )
651673{
652674   if( VERBOSE_LEVEL >= n_level )
653675   {
r21058r21059
656678      va_start( v, s_fmt );
657679      vsprintf( buf, s_fmt, v );
658680      va_end( v );
659      logerror( "%s: %s", machine.describe_context(), buf );
681      logerror( "%s: %s", machine().describe_context(), buf );
660682   }
661683}
662684
663685WRITE32_MEMBER(ksys573_state::mb89371_w)
664686{
665   verboselog( machine(), 2, "mb89371_w %08x %08x %08x\n", offset, mem_mask, data );
687   verboselog(2, "mb89371_w %08x %08x %08x\n", offset, mem_mask, data );
666688}
667689
668690READ32_MEMBER(ksys573_state::mb89371_r)
669691{
670692   UINT32 data = 0xffffffff;
671   verboselog( machine(), 2, "mb89371_r %08x %08x %08x\n", offset, mem_mask, data );
693   verboselog(2, "mb89371_r %08x %08x %08x\n", offset, mem_mask, data );
672694   return data;
673695}
674696
r21058r21059
698720      data |= ( 1 << 27 );
699721   }
700722
701   verboselog( machine(), 2, "jamma_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
723   verboselog(2, "jamma_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
702724
703725   return data;
704726}
705727
706728READ32_MEMBER(ksys573_state::control_r)
707729{
708   verboselog( machine(), 2, "control_r( %08x, %08x ) %08x\n", offset, mem_mask, m_control );
730   verboselog(2, "control_r( %08x, %08x ) %08x\n", offset, mem_mask, m_control );
709731
710732   return m_control;
711733}
r21058r21059
718740   COMBINE_DATA(&m_control);
719741   control = m_control;
720742
721   verboselog( machine(), 2, "control_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
743   verboselog(2, "control_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
722744
723745   m_flash_bank = -1;
724746
r21058r21059
730752   if( m_flash_device[0][0] != NULL && ( control & ~0x43 ) == 0x00 )
731753   {
732754      m_flash_bank = (0 << 8) + ( ( control & 3 ) * 2 );
733      if( m_flash_bank != old_bank ) verboselog( machine(), 1, "onboard %d\n", control & 3 );
755      if( m_flash_bank != old_bank ) verboselog(1, "onboard %d\n", control & 3 );
734756   }
735757   else if( m_flash_device[1][0] != NULL && ( control & ~0x47 ) == 0x10 )
736758   {
737759      m_flash_bank = (1 << 8) + ( ( control & 7 ) * 2 );
738      if( m_flash_bank != old_bank ) verboselog( machine(), 1, "pccard1 %d\n", control & 7 );
760      if( m_flash_bank != old_bank ) verboselog(1, "pccard1 %d\n", control & 7 );
739761   }
740762   else if( m_flash_device[2][0] != NULL && ( control & ~0x47 ) == 0x20 )
741763   {
742764      m_flash_bank = (2 << 8) + ( ( control & 7 ) * 2 );
743      if( m_flash_bank != old_bank ) verboselog( machine(), 1, "pccard2 %d\n", control & 7 );
765      if( m_flash_bank != old_bank ) verboselog(1, "pccard2 %d\n", control & 7 );
744766   }
745767   else if( m_flash_device[3][0] != NULL && ( control & ~0x47 ) == 0x20 )
746768   {
747769      m_flash_bank = (3 << 8) + ( ( control & 7 ) * 2 );
748      if( m_flash_bank != old_bank ) verboselog( machine(), 1, "pccard3 %d\n", control & 7 );
770      if( m_flash_bank != old_bank ) verboselog(1, "pccard3 %d\n", control & 7 );
749771   }
750772   else if( m_flash_device[4][0] != NULL && ( control & ~0x47 ) == 0x28 )
751773   {
752774      m_flash_bank = (4 << 8) + ( ( control & 7 ) * 2 );
753      if( m_flash_bank != old_bank ) verboselog( machine(), 1, "pccard4 %d\n", control & 7 );
775      if( m_flash_bank != old_bank ) verboselog(1, "pccard4 %d\n", control & 7 );
754776   }
755777}
756778
r21058r21059
763785
764786   m_atapi_timer->adjust(attotime::never);
765787
766//  verboselog( machine(), 2, "atapi_xfer_end( %d ) atapi_xferlen = %d, atapi_xfermod=%d\n", x, atapi_xfermod, atapi_xferlen );
788//  verboselog(2, "atapi_xfer_end( %d ) atapi_xferlen = %d, atapi_xfermod=%d\n", x, atapi_xfermod, atapi_xferlen );
767789
768790//  mame_printf_debug("ATAPI: xfer_end.  xferlen = %d, atapi_xfermod = %d\n", atapi_xferlen, atapi_xfermod);
769791
r21058r21059
818840
819841   m_psxirq->intin10(1);
820842
821   verboselog( machine(), 2, "atapi_xfer_end: %d %d\n", m_atapi_xferlen, m_atapi_xfermod );
843   verboselog(2, "atapi_xfer_end: %d %d\n", m_atapi_xferlen, m_atapi_xfermod );
822844}
823845
824846READ32_MEMBER(ksys573_state::atapi_r)
r21058r21059
851873            m_atapi_xfermod = 0;
852874         }
853875
854         verboselog( machine(), 2, "atapi_r: atapi_xferlen=%d\n", m_atapi_xferlen );
876         verboselog(2, "atapi_r: atapi_xferlen=%d\n", m_atapi_xferlen );
855877         if( m_atapi_xferlen != 0 )
856878         {
857879            atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
r21058r21059
876898         data |= ( m_atapi_data[m_atapi_data_ptr++] << 8 );
877899         if( m_atapi_data_ptr >= m_atapi_data_len )
878900         {
879//              verboselog( machine(), 2, "atapi_r: read all bytes\n" );
901//              verboselog(2, "atapi_r: read all bytes\n" );
880902            m_atapi_data_ptr = 0;
881903            m_atapi_data_len = 0;
882904
r21058r21059
909931      switch( reg )
910932      {
911933      case ATAPI_REG_DATA:
912         verboselog( machine(), 1, "atapi_r: data=%02x\n", data );
934         verboselog(1, "atapi_r: data=%02x\n", data );
913935         break;
914936      case ATAPI_REG_ERRFEAT:
915         verboselog( machine(), 1, "atapi_r: errfeat=%02x\n", data );
937         verboselog(1, "atapi_r: errfeat=%02x\n", data );
916938         break;
917939      case ATAPI_REG_INTREASON:
918         verboselog( machine(), 1, "atapi_r: intreason=%02x\n", data );
940         verboselog(1, "atapi_r: intreason=%02x\n", data );
919941         break;
920942      case ATAPI_REG_SAMTAG:
921         verboselog( machine(), 1, "atapi_r: samtag=%02x\n", data );
943         verboselog(1, "atapi_r: samtag=%02x\n", data );
922944         break;
923945      case ATAPI_REG_COUNTLOW:
924         verboselog( machine(), 1, "atapi_r: countlow=%02x\n", data );
946         verboselog(1, "atapi_r: countlow=%02x\n", data );
925947         break;
926948      case ATAPI_REG_COUNTHIGH:
927         verboselog( machine(), 1, "atapi_r: counthigh=%02x\n", data );
949         verboselog(1, "atapi_r: counthigh=%02x\n", data );
928950         break;
929951      case ATAPI_REG_DRIVESEL:
930         verboselog( machine(), 1, "atapi_r: drivesel=%02x\n", data );
952         verboselog(1, "atapi_r: drivesel=%02x\n", data );
931953         break;
932954      case ATAPI_REG_CMDSTATUS:
933         verboselog( machine(), 1, "atapi_r: cmdstatus=%02x\n", data );
955         verboselog(1, "atapi_r: cmdstatus=%02x\n", data );
934956         break;
935957      }
936958
r21058r21059
939961      data <<= shift;
940962   }
941963
942   verboselog( machine(), 2, "atapi_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
964   verboselog(2, "atapi_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
943965   return data;
944966}
945967
r21058r21059
949971   UINT8 *atapi_data = m_atapi_data;
950972   int reg;
951973
952   verboselog( machine(), 2, "atapi_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
974   verboselog(2, "atapi_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
953975
954976   if (mem_mask == 0x0000ffff) // word-wide command write
955977   {
956      verboselog( machine(), 2, "atapi_w: data=%04x\n", data );
978      verboselog(2, "atapi_w: data=%04x\n", data );
957979
958980//      mame_printf_debug("ATAPI: packet write %04x\n", data);
959981      atapi_data[m_atapi_data_ptr++] = data & 0xff;
r21058r21059
9791001      {
9801002         int phase;
9811003
982         verboselog( machine(), 2, "atapi_w: command %02x\n", atapi_data[0]&0xff );
1004         verboselog(2, "atapi_w: command %02x\n", atapi_data[0]&0xff );
9831005
9841006         // reset data pointer for reading SCSI results
9851007         m_atapi_data_ptr = 0;
r21058r21059
10661088      switch( reg )
10671089      {
10681090      case ATAPI_REG_DATA:
1069         verboselog( machine(), 1, "atapi_w: data=%02x\n", data );
1091         verboselog(1, "atapi_w: data=%02x\n", data );
10701092         break;
10711093      case ATAPI_REG_ERRFEAT:
1072         verboselog( machine(), 1, "atapi_w: errfeat=%02x\n", data );
1094         verboselog(1, "atapi_w: errfeat=%02x\n", data );
10731095         break;
10741096      case ATAPI_REG_INTREASON:
1075         verboselog( machine(), 1, "atapi_w: intreason=%02x\n", data );
1097         verboselog(1, "atapi_w: intreason=%02x\n", data );
10761098         break;
10771099      case ATAPI_REG_SAMTAG:
1078         verboselog( machine(), 1, "atapi_w: samtag=%02x\n", data );
1100         verboselog(1, "atapi_w: samtag=%02x\n", data );
10791101         break;
10801102      case ATAPI_REG_COUNTLOW:
1081         verboselog( machine(), 1, "atapi_w: countlow=%02x\n", data );
1103         verboselog(1, "atapi_w: countlow=%02x\n", data );
10821104         break;
10831105      case ATAPI_REG_COUNTHIGH:
1084         verboselog( machine(), 1, "atapi_w: counthigh=%02x\n", data );
1106         verboselog(1, "atapi_w: counthigh=%02x\n", data );
10851107         break;
10861108      case ATAPI_REG_DRIVESEL:
1087         verboselog( machine(), 1, "atapi_w: drivesel=%02x\n", data );
1109         verboselog(1, "atapi_w: drivesel=%02x\n", data );
10881110         break;
10891111      case ATAPI_REG_CMDSTATUS:
1090         verboselog( machine(), 1, "atapi_w: cmdstatus=%02x\n", data );
1112         verboselog(1, "atapi_w: cmdstatus=%02x\n", data );
10911113         break;
10921114      }
10931115
r21058r21059
11781200   }
11791201}
11801202
1181static void atapi_init(running_machine &machine)
1203void ksys573_state::atapi_init()
11821204{
1183   ksys573_state *state = machine.driver_data<ksys573_state>();
11841205
1185   state->m_atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
1186   state->m_atapi_regs[ATAPI_REG_ERRFEAT] = 1;
1187   state->m_atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
1188   state->m_atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
1206   m_atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
1207   m_atapi_regs[ATAPI_REG_ERRFEAT] = 1;
1208   m_atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
1209   m_atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
11891210
1190   state->m_atapi_data_ptr = 0;
1191   state->m_atapi_data_len = 0;
1192   state->m_atapi_cdata_wait = 0;
1211   m_atapi_data_ptr = 0;
1212   m_atapi_data_len = 0;
1213   m_atapi_cdata_wait = 0;
11931214
1194   state->m_atapi_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(ksys573_state::atapi_xfer_end),state));
1195   state->m_atapi_timer->adjust(attotime::never);
1215   m_atapi_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ksys573_state::atapi_xfer_end),this));
1216   m_atapi_timer->adjust(attotime::never);
11961217
1197   state->m_available_cdroms[ 0 ] = cdrom_open( get_disk_handle( machine, ":cdrom0" ) );
1198   state->m_available_cdroms[ 1 ] = cdrom_open( get_disk_handle( machine, ":cdrom1" ) );
1218   m_available_cdroms[ 0 ] = cdrom_open( get_disk_handle( machine(), ":cdrom0" ) );
1219   m_available_cdroms[ 1 ] = cdrom_open( get_disk_handle( machine(), ":cdrom1" ) );
11991220
1200   state->save_item( NAME(state->m_atapi_regs) );
1201   state->save_item( NAME(state->m_atapi_data) );
1202   state->save_item( NAME(state->m_atapi_data_ptr) );
1203   state->save_item( NAME(state->m_atapi_data_len) );
1204   state->save_item( NAME(state->m_atapi_xferlen) );
1205   state->save_item( NAME(state->m_atapi_xferbase) );
1206   state->save_item( NAME(state->m_atapi_cdata_wait) );
1207   state->save_item( NAME(state->m_atapi_xfermod) );
1221   save_item( NAME(m_atapi_regs) );
1222   save_item( NAME(m_atapi_data) );
1223   save_item( NAME(m_atapi_data_ptr) );
1224   save_item( NAME(m_atapi_data_len) );
1225   save_item( NAME(m_atapi_xferlen) );
1226   save_item( NAME(m_atapi_xferbase) );
1227   save_item( NAME(m_atapi_cdata_wait) );
1228   save_item( NAME(m_atapi_xfermod) );
12081229}
12091230
12101231WRITE32_MEMBER(ksys573_state::atapi_reset_w)
12111232{
12121233   UINT8 *atapi_regs = m_atapi_regs;
12131234
1214   verboselog( machine(), 2, "atapi_reset_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
1235   verboselog(2, "atapi_reset_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
12151236
12161237   if (data)
12171238   {
1218      verboselog( machine(), 2, "atapi_reset_w: reset\n" );
1239      verboselog(2, "atapi_reset_w: reset\n" );
12191240
12201241//      mame_printf_debug("ATAPI reset\n");
12211242
r21058r21059
12331254   }
12341255}
12351256
1236static void cdrom_dma_read( ksys573_state *state, UINT32 *ram, UINT32 n_address, INT32 n_size )
1257void ksys573_state::cdrom_dma_read( UINT32 *ram, UINT32 n_address, INT32 n_size )
12371258{
1238   verboselog( state->machine(), 2, "cdrom_dma_read( %08x, %08x )\n", n_address, n_size );
1259   verboselog(2, "cdrom_dma_read( %08x, %08x )\n", n_address, n_size );
12391260//  mame_printf_debug("DMA read: address %08x size %08x\n", n_address, n_size);
12401261}
12411262
1242static void cdrom_dma_write( ksys573_state *state, UINT32 *ram, UINT32 n_address, INT32 n_size )
1263void ksys573_state::cdrom_dma_write( UINT32 *ram, UINT32 n_address, INT32 n_size )
12431264{
1244   state->m_p_n_psxram = ram;
1265   m_p_n_psxram = ram;
12451266
1246   verboselog( state->machine(), 2, "cdrom_dma_write( %08x, %08x )\n", n_address, n_size );
1267   verboselog(2, "cdrom_dma_write( %08x, %08x )\n", n_address, n_size );
12471268//  mame_printf_debug("DMA write: address %08x size %08x\n", n_address, n_size);
12481269
1249   state->m_atapi_xferbase = n_address;
1270   m_atapi_xferbase = n_address;
12501271
1251   verboselog( state->machine(), 2, "atapi_xfer_end: %d %d\n", state->m_atapi_xferlen, state->m_atapi_xfermod );
1272   verboselog(2, "atapi_xfer_end: %d %d\n", m_atapi_xferlen, m_atapi_xfermod );
12521273
12531274   // set a transfer complete timer (Note: CYCLES_PER_SECTOR can't be lower than 2000 or the BIOS ends up "out of order")
1254   state->m_atapi_timer->adjust(state->machine().device<cpu_device>("maincpu")->cycles_to_attotime((ATAPI_CYCLES_PER_SECTOR * (state->m_atapi_xferlen/2048))));
1275   m_atapi_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime((ATAPI_CYCLES_PER_SECTOR * (m_atapi_xferlen/2048))));
12551276}
12561277
12571278WRITE32_MEMBER(ksys573_state::security_w)
r21058r21059
12591280   int security_cart_number = m_security_cart_number;
12601281   COMBINE_DATA( &m_n_security_control );
12611282
1262   verboselog( machine(), 2, "security_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
1283   verboselog(2, "security_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
12631284
12641285   if( ACCESSING_BITS_0_15 )
12651286   {
r21058r21059
12811302
12821303      if( m_security_callback != NULL )
12831304      {
1284         (*m_security_callback)( machine(), data & 0xff );
1305         (this->*m_security_callback)( data & 0xff );
12851306      }
12861307   }
12871308
r21058r21059
12911312READ32_MEMBER(ksys573_state::security_r)
12921313{
12931314   UINT32 data = m_n_security_control;
1294   verboselog( machine(), 2, "security_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
1315   verboselog(2, "security_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
12951316   return data;
12961317}
12971318
r21058r21059
13181339      }
13191340   }
13201341
1321   verboselog( machine(), 2, "flash_r( %08x, %04x) %04x bank = %04x\n", offset, mem_mask, data, m_flash_bank );
1342   verboselog(2, "flash_r( %08x, %04x) %04x bank = %04x\n", offset, mem_mask, data, m_flash_bank );
13221343
13231344   return data;
13241345}
13251346
13261347WRITE16_MEMBER(ksys573_state::flash_w)
13271348{
1328   verboselog( machine(), 2, "flash_w( %08x, %04x, %04x) bank = %04x\n", offset, mem_mask, data, m_flash_bank );
1349   verboselog(2, "flash_w( %08x, %04x, %04x) bank = %04x\n", offset, mem_mask, data, m_flash_bank );
13291350
13301351   if( m_flash_bank < 0 )
13311352   {
r21058r21059
13691390
13701391
13711392
1372static void flash_init( running_machine &machine )
1393void ksys573_state::flash_init(  )
13731394{
13741395   // find onboard flash devices
1375   ksys573_state *state = machine.driver_data<ksys573_state>();
13761396   astring tempstr;
13771397   for (int index = 0; index < 8; index++)
1378      state->m_flash_device[0][index] = machine.device<fujitsu_29f016a_device>(tempstr.format("onboard.%d", index));
1398      m_flash_device[0][index] = machine().device<fujitsu_29f016a_device>(tempstr.format("onboard.%d", index));
13791399
13801400   // find pccard flash devices
13811401   for (int card = 1; card <= 4; card++)
13821402      for (int index = 0; index < 16; index++)
1383         state->m_flash_device[card][index] = machine.device<fujitsu_29f016a_device>(tempstr.format("pccard%d.%d", card, index));
1403         m_flash_device[card][index] = machine().device<fujitsu_29f016a_device>(tempstr.format("pccard%d.%d", card, index));
13841404
1385   state->save_item( NAME(state->m_flash_bank) );
1386   state->save_item( NAME(state->m_control) );
1405   save_item( NAME(m_flash_bank) );
1406   save_item( NAME(m_control) );
13871407}
13881408
1389static void update_mode( running_machine &machine )
1409void ksys573_state::update_mode(  )
13901410{
1391   ksys573_state *state = machine.driver_data<ksys573_state>();
1392   int cart = state->ioport("CART")->read();
1393   int cd = state->ioport( "CD" )->read();
1411   int cart = ioport("CART")->read();
1412   int cd = ioport( "CD" )->read();
13941413   cdrom_file *new_cdrom;
13951414
1396   if( state->machine().device<device_secure_serial_flash>("game_eeprom") )
1415   if( machine().device<device_secure_serial_flash>("game_eeprom") )
13971416   {
1398      state->m_security_cart_number = cart;
1417      m_security_cart_number = cart;
13991418   }
14001419   else
14011420   {
1402      state->m_security_cart_number = 0;
1421      m_security_cart_number = 0;
14031422   }
14041423
1405   if( state->m_available_cdroms[ 1 ] != NULL )
1424   if( m_available_cdroms[ 1 ] != NULL )
14061425   {
1407      new_cdrom = state->m_available_cdroms[ cd ];
1426      new_cdrom = m_available_cdroms[ cd ];
14081427   }
14091428   else
14101429   {
1411      new_cdrom = state->m_available_cdroms[ 0 ];
1430      new_cdrom = m_available_cdroms[ 0 ];
14121431   }
14131432
14141433   void *current_cdrom;
1415   state->m_cr589->GetDevice( &current_cdrom );
1434   m_cr589->GetDevice( &current_cdrom );
14161435
14171436   if( current_cdrom != new_cdrom )
14181437   {
14191438      current_cdrom = new_cdrom;
14201439
1421      state->m_cr589->SetDevice( new_cdrom );
1440      m_cr589->SetDevice( new_cdrom );
14221441   }
14231442}
14241443
14251444DRIVER_INIT_MEMBER(ksys573_state,konami573)
14261445{
1427   atapi_init(machine());
1446   atapi_init();
14281447
14291448   save_item( NAME(m_n_security_control) );
14301449
1431   flash_init(machine());
1450   flash_init();
14321451}
14331452
14341453MACHINE_RESET_MEMBER(ksys573_state,konami573)
14351454{
14361455   m_flash_bank = -1;
14371456
1438   update_mode(machine());
1457   update_mode();
14391458}
14401459
1441void sys573_vblank(ksys573_state *state, screen_device &screen, bool vblank_state)
1460void ksys573_state::sys573_vblank(screen_device &screen, bool vblank_state)
14421461{
1443   update_mode(state->machine());
1462   update_mode();
14441463
14451464   /// TODO: emulate the memory controller board
1446   if( strcmp( state->machine().system().name, "ddr2ml" ) == 0 )
1465   if( strcmp( machine().system().name, "ddr2ml" ) == 0 )
14471466   {
14481467      /* patch out security-plate error */
14491468
1450      UINT32 *p_n_psxram = (UINT32 *)state->memshare("share1")->ptr();
1469      UINT32 *p_n_psxram = (UINT32 *)memshare("share1")->ptr();
14511470
14521471      /* install cd */
14531472
r21058r21059
14671486         p_n_psxram[ 0x1f850 / 4 ] = 0x08007e22;
14681487      }
14691488   }
1470   else if( strcmp( state->machine().system().name, "ddr2mla" ) == 0 )
1489   else if( strcmp( machine().system().name, "ddr2mla" ) == 0 )
14711490   {
14721491      /* patch out security-plate error */
14731492
1474      UINT32 *p_n_psxram = (UINT32 *)state->memshare("share1")->ptr();
1493      UINT32 *p_n_psxram = (UINT32 *)memshare("share1")->ptr();
14751494      /* 8001f850: jal $8003221c */
14761495      if( p_n_psxram[ 0x1f850 / 4 ] == 0x0c00c887 )
14771496      {
r21058r21059
15211540      break;
15221541
15231542   default:
1524      verboselog(machine(), 0, "ge765pwbba_r: unhandled offset %08x %08x\n", offset, mem_mask);
1543      verboselog(0, "ge765pwbba_r: unhandled offset %08x %08x\n", offset, mem_mask);
15251544      break;
15261545   }
15271546
1528   verboselog(machine(), 2, "ge765pwbba_r( %08x, %08x ) %08x\n", offset, mem_mask, data);
1547   verboselog(2, "ge765pwbba_r( %08x, %08x ) %08x\n", offset, mem_mask, data);
15291548   return data;
15301549}
15311550
r21058r21059
15601579      break;
15611580
15621581   default:
1563      verboselog(machine(), 0, "ge765pwbba_w: unhandled offset %08x %08x %08x\n", offset, mem_mask, data);
1582      verboselog(0, "ge765pwbba_w: unhandled offset %08x %08x %08x\n", offset, mem_mask, data);
15641583      break;
15651584   }
15661585
1567   verboselog(machine(), 2, "ge765pwbba_w( %08x, %08x, %08x )\n", offset, mem_mask, data);
1586   verboselog(2, "ge765pwbba_w( %08x, %08x, %08x )\n", offset, mem_mask, data);
15681587}
15691588
15701589DRIVER_INIT_MEMBER(ksys573_state,ge765pwbba)
r21058r21059
16071626      break;
16081627   }
16091628
1610   verboselog( machine(), 2, "gx700pwbf_io_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
1629   verboselog(2, "gx700pwbf_io_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
16111630
16121631   return data;
16131632}
16141633
1615static void gx700pwbf_output( running_machine &machine, int offset, UINT8 data )
1634void ksys573_state::gx700pwbf_output( int offset, UINT8 data )
16161635{
1617   ksys573_state *state = machine.driver_data<ksys573_state>();
16181636
1619   if( state->m_gx700pwfbf_output_callback != NULL )
1637   if( m_gx700pwfbf_output_callback != NULL )
16201638   {
16211639      int i;
16221640      static const int shift[] = { 7, 6, 1, 0, 5, 4, 3, 2 };
16231641      for( i = 0; i < 8; i++ )
16241642      {
1625         int oldbit = ( state->m_gx700pwbf_output_data[ offset ] >> shift[ i ] ) & 1;
1643         int oldbit = ( m_gx700pwbf_output_data[ offset ] >> shift[ i ] ) & 1;
16261644         int newbit = ( data >> shift[ i ] ) & 1;
16271645         if( oldbit != newbit )
16281646         {
1629            (*state->m_gx700pwfbf_output_callback)( machine, ( offset * 8 ) + i, newbit );
1647            (this->*m_gx700pwfbf_output_callback)( ( offset * 8 ) + i, newbit );
16301648         }
16311649      }
16321650   }
1633   state->m_gx700pwbf_output_data[ offset ] = data;
1651   m_gx700pwbf_output_data[ offset ] = data;
16341652}
16351653
16361654WRITE32_MEMBER(ksys573_state::gx700pwbf_io_w)
16371655{
1638   verboselog( machine(), 2, "gx700pwbf_io_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
1656   verboselog(2, "gx700pwbf_io_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
16391657
16401658   switch( offset )
16411659   {
r21058r21059
16431661
16441662      if( ACCESSING_BITS_0_15 )
16451663      {
1646         gx700pwbf_output( machine(), 0, data & 0xff );
1664         gx700pwbf_output( 0, data & 0xff );
16471665      }
16481666      break;
16491667
16501668   case 0x22:
16511669      if( ACCESSING_BITS_0_15 )
16521670      {
1653         gx700pwbf_output( machine(), 1, data & 0xff );
1671         gx700pwbf_output( 1, data & 0xff );
16541672      }
16551673      break;
16561674
16571675   case 0x24:
16581676      if( ACCESSING_BITS_0_15 )
16591677      {
1660         gx700pwbf_output( machine(), 2, data & 0xff );
1678         gx700pwbf_output( 2, data & 0xff );
16611679      }
16621680      break;
16631681
16641682   case 0x26:
16651683      if( ACCESSING_BITS_0_15 )
16661684      {
1667         gx700pwbf_output( machine(), 3, data & 0xff );
1685         gx700pwbf_output( 3, data & 0xff );
16681686      }
16691687      break;
16701688
r21058r21059
16741692   }
16751693}
16761694
1677static void gx700pwfbf_init( running_machine &machine, void (*output_callback_func)( running_machine &machine, int offset, int data ) )
1695void ksys573_state::gx700pwfbf_init( void (ksys573_state::*output_callback_func)( int offset, int data ) )
16781696{
1679   ksys573_state *state = machine.driver_data<ksys573_state>();
16801697
1681   memset( state->m_gx700pwbf_output_data, 0, sizeof( state->m_gx700pwbf_output_data ) );
1698   memset( m_gx700pwbf_output_data, 0, sizeof( m_gx700pwbf_output_data ) );
16821699
1683   state->m_gx700pwfbf_output_callback = output_callback_func;
1700   m_gx700pwfbf_output_callback = output_callback_func;
16841701
1685   machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x1f640000, 0x1f6400ff, read32_delegate(FUNC(ksys573_state::gx700pwbf_io_r),state), write32_delegate(FUNC(ksys573_state::gx700pwbf_io_w),state));
1702   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x1f640000, 0x1f6400ff, read32_delegate(FUNC(ksys573_state::gx700pwbf_io_r),this), write32_delegate(FUNC(ksys573_state::gx700pwbf_io_w),this));
16861703
1687   state->save_item( NAME(state->m_gx700pwbf_output_data) );
1704   save_item( NAME(m_gx700pwbf_output_data) );
16881705}
16891706
16901707/*
r21058r21059
17081725   0, 4, 0, 6
17091726};
17101727
1711static void gn845pwbb_do_w( running_machine &machine, int offset, int data )
1728void ksys573_state::gn845pwbb_do_w( int offset, int data )
17121729{
1713   ksys573_state *state = machine.driver_data<ksys573_state>();
17141730
1715   state->m_stage[ offset ].DO = !data;
1731   m_stage[ offset ].DO = !data;
17161732}
17171733
1718static void gn845pwbb_clk_w( running_machine &machine, int offset, int data )
1734void ksys573_state::gn845pwbb_clk_w( int offset, int data )
17191735{
1720   ksys573_state *state = machine.driver_data<ksys573_state>();
17211736   int clk = !data;
17221737
1723   if( clk != state->m_stage[ offset ].clk )
1738   if( clk != m_stage[ offset ].clk )
17241739   {
1725      state->m_stage[ offset ].clk = clk;
1740      m_stage[ offset ].clk = clk;
17261741
17271742      if( clk )
17281743      {
1729         state->m_stage[ offset ].shift = ( state->m_stage[ offset ].shift >> 1 ) | ( state->m_stage[ offset ].DO << 12 );
1744         m_stage[ offset ].shift = ( m_stage[ offset ].shift >> 1 ) | ( m_stage[ offset ].DO << 12 );
17301745
1731         switch( state->m_stage[ offset ].state )
1746         switch( m_stage[ offset ].state )
17321747         {
17331748         case DDR_STAGE_IDLE:
1734            if( state->m_stage[ offset ].shift == 0xc90 )
1749            if( m_stage[ offset ].shift == 0xc90 )
17351750            {
1736               state->m_stage[ offset ].state = DDR_STAGE_INIT;
1737               state->m_stage[ offset ].bit = 0;
1738               state->m_stage_mask = 0xfffff9f9;
1751               m_stage[ offset ].state = DDR_STAGE_INIT;
1752               m_stage[ offset ].bit = 0;
1753               m_stage_mask = 0xfffff9f9;
17391754            }
17401755            break;
17411756
17421757         case DDR_STAGE_INIT:
1743            state->m_stage[ offset ].bit++;
1744            if( state->m_stage[ offset ].bit < 22 )
1758            m_stage[ offset ].bit++;
1759            if( m_stage[ offset ].bit < 22 )
17451760            {
1746               int a = ( ( ( ( ~0x06 ) | mask[ state->m_stage[ 0 ].bit ] ) & 0xff ) << 8 );
1747               int b = ( ( ( ( ~0x06 ) | mask[ state->m_stage[ 1 ].bit ] ) & 0xff ) << 0 );
1761               int a = ( ( ( ( ~0x06 ) | mask[ m_stage[ 0 ].bit ] ) & 0xff ) << 8 );
1762               int b = ( ( ( ( ~0x06 ) | mask[ m_stage[ 1 ].bit ] ) & 0xff ) << 0 );
17481763
1749               state->m_stage_mask = 0xffff0000 | a | b;
1764               m_stage_mask = 0xffff0000 | a | b;
17501765            }
17511766            else
17521767            {
1753               state->m_stage[ offset ].bit = 0;
1754               state->m_stage[ offset ].state = DDR_STAGE_IDLE;
1768               m_stage[ offset ].bit = 0;
1769               m_stage[ offset ].state = DDR_STAGE_IDLE;
17551770
1756               state->m_stage_mask = 0xffffffff;
1771               m_stage_mask = 0xffffffff;
17571772            }
17581773            break;
17591774         }
17601775      }
17611776   }
17621777
1763   verboselog( machine, 2, "stage: %dp data clk=%d state=%d d0=%d shift=%08x bit=%d stage_mask=%08x\n", offset + 1, clk,
1764      state->m_stage[ offset ].state, state->m_stage[ offset ].DO, state->m_stage[ offset ].shift, state->m_stage[ offset ].bit, state->m_stage_mask );
1778   verboselog( 2, "stage: %dp data clk=%d state=%d d0=%d shift=%08x bit=%d stage_mask=%08x\n", offset + 1, clk,
1779      m_stage[ offset ].state, m_stage[ offset ].DO, m_stage[ offset ].shift, m_stage[ offset ].bit, m_stage_mask );
17651780}
17661781
17671782CUSTOM_INPUT_MEMBER(ksys573_state::gn845pwbb_read)
r21058r21059
17691784   return ioport("STAGE")->read() & m_stage_mask;
17701785}
17711786
1772static void gn845pwbb_output_callback( running_machine &machine, int offset, int data )
1787void ksys573_state::gn845pwbb_output_callback( int offset, int data )
17731788{
17741789   switch( offset )
17751790   {
r21058r21059
17901805      break;
17911806
17921807   case 4:
1793      gn845pwbb_do_w( machine, 0, !data );
1808      gn845pwbb_do_w( 0, !data );
17941809      break;
17951810
17961811   case 7:
1797      gn845pwbb_clk_w( machine, 0, !data );
1812      gn845pwbb_clk_w( 0, !data );
17981813      break;
17991814
18001815   case 8:
r21058r21059
18141829      break;
18151830
18161831   case 12:
1817      gn845pwbb_do_w( machine, 1, !data );
1832      gn845pwbb_do_w( 1, !data );
18181833      break;
18191834
18201835   case 15:
1821      gn845pwbb_clk_w( machine, 1, !data );
1836      gn845pwbb_clk_w( 1, !data );
18221837      break;
18231838
18241839   case 17:
r21058r21059
18611876   DRIVER_INIT_CALL(konami573);
18621877
18631878   m_stage_mask = 0xffffffff;
1864   gx700pwfbf_init( machine(), gn845pwbb_output_callback );
1879   gx700pwfbf_init( &ksys573_state::gn845pwbb_output_callback );
18651880
18661881   save_item( NAME(m_stage_mask) );
18671882}
r21058r21059
18851900      break;
18861901
18871902   default:
1888      verboselog( machine(), 0, "gtrfrks_io_r: unhandled offset %08x, %08x\n", offset, mem_mask );
1903      verboselog(0, "gtrfrks_io_r: unhandled offset %08x, %08x\n", offset, mem_mask );
18891904      break;
18901905   }
18911906
1892   verboselog( machine(), 2, "gtrfrks_io_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
1907   verboselog(2, "gtrfrks_io_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
18931908   return data;
18941909}
18951910
18961911WRITE32_MEMBER(ksys573_state::gtrfrks_io_w)
18971912{
1898   verboselog( machine(), 2, "gtrfrks_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
1913   verboselog(2, "gtrfrks_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
18991914
19001915   switch( offset )
19011916   {
r21058r21059
19101925      break;
19111926
19121927   default:
1913      verboselog( machine(), 0, "gtrfrks_io_w: unhandled offset %08x, %08x\n", offset, mem_mask );
1928      verboselog(0, "gtrfrks_io_w: unhandled offset %08x, %08x\n", offset, mem_mask );
19141929      break;
19151930   }
19161931}
r21058r21059
20252040      break;
20262041   }
20272042
2028   verboselog( machine(), 2, "gx894pwbba_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
2043   verboselog(2, "gx894pwbba_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
20292044//  printf( "%08x: gx894pwbba_r( %08x, %08x ) %08x\n", space.device().safe_pc(), offset, mem_mask, data );
20302045   return data;
20312046}
20322047
2033static char *binary( char *s, UINT32 data )
2048char *ksys573_state::binary( char *s, UINT32 data )
20342049{
20352050   int i;
20362051   for( i = 0; i < 32; i++ )
r21058r21059
20412056   return s;
20422057}
20432058
2044static void gx894pwbba_output( running_machine &machine, int offset, UINT8 data )
2059void ksys573_state::gx894pwbba_output( int offset, UINT8 data )
20452060{
2046   ksys573_state *state = machine.driver_data<ksys573_state>();
20472061
2048   if( state->m_gx894pwbba_output_callback != NULL )
2062   if( m_gx894pwbba_output_callback != NULL )
20492063   {
20502064      int i;
20512065      static const int shift[] = { 0, 2, 3, 1 };
20522066      for( i = 0; i < 4; i++ )
20532067      {
2054         int oldbit = ( state->m_gx894pwbba_output_data[ offset ] >> shift[ i ] ) & 1;
2068         int oldbit = ( m_gx894pwbba_output_data[ offset ] >> shift[ i ] ) & 1;
20552069         int newbit = ( data >> shift[ i ] ) & 1;
20562070         if( oldbit != newbit )
20572071         {
2058            (*state->m_gx894pwbba_output_callback)( machine, ( offset * 4 ) + i, newbit );
2072            (this->*m_gx894pwbba_output_callback)( ( offset * 4 ) + i, newbit );
20592073         }
20602074      }
20612075   }
2062   state->m_gx894pwbba_output_data[ offset ] = data;
2076   m_gx894pwbba_output_data[ offset ] = data;
20632077}
20642078
20652079WRITE32_MEMBER(ksys573_state::gx894pwbba_w)
r21058r21059
20742088      return;
20752089   }
20762090
2077   verboselog( machine(), 2, "gx894pwbba_w( %08x, %08x, %08x) %s\n", offset, mem_mask, data, binary( buff, data ) );
2091   verboselog(2, "gx894pwbba_w( %08x, %08x, %08x) %s\n", offset, mem_mask, data, binary( buff, data ) );
20782092
20792093   switch( offset )
20802094   {
r21058r21059
21462160   case 0x38:
21472161      if( ACCESSING_BITS_16_31 )
21482162      {
2149         gx894pwbba_output( machine(), 0, ( data >> 28 ) & 0xf );
2163         gx894pwbba_output( 0, ( data >> 28 ) & 0xf );
21502164      }
21512165      if( ACCESSING_BITS_0_15 )
21522166      {
2153         gx894pwbba_output( machine(), 1, ( data >> 12 ) & 0xf );
2167         gx894pwbba_output( 1, ( data >> 12 ) & 0xf );
21542168      }
21552169      COMBINE_DATA( &m_a );
21562170      break;
21572171   case 0x39:
21582172      if( ACCESSING_BITS_16_31 )
21592173      {
2160         gx894pwbba_output( machine(), 7, ( data >> 28 ) & 0xf );
2174         gx894pwbba_output( 7, ( data >> 28 ) & 0xf );
21612175      }
21622176      if( ACCESSING_BITS_0_15 )
21632177      {
2164         gx894pwbba_output( machine(), 3, ( data >> 12 ) & 0xf );
2178         gx894pwbba_output( 3, ( data >> 12 ) & 0xf );
21652179      }
21662180      COMBINE_DATA( &m_b );
21672181      break;
r21058r21059
21992213
22002214      if( ACCESSING_BITS_16_31 )
22012215      {
2202         gx894pwbba_output( machine(), 4, ( data >> 28 ) & 0xf );
2216         gx894pwbba_output( 4, ( data >> 28 ) & 0xf );
22032217      }
22042218      COMBINE_DATA( &m_c );
22052219      break;
22062220   case 0x3f:
22072221      if( ACCESSING_BITS_16_31 )
22082222      {
2209         gx894pwbba_output( machine(), 2, ( data >> 28 ) & 0xf );
2223         gx894pwbba_output( 2, ( data >> 28 ) & 0xf );
22102224      }
22112225      if( ACCESSING_BITS_0_15 )
22122226      {
2213         gx894pwbba_output( machine(), 5, ( data >> 12 ) & 0xf );
2227         gx894pwbba_output( 5, ( data >> 12 ) & 0xf );
22142228      }
22152229      COMBINE_DATA( &m_d );
22162230      break;
r21058r21059
22242238   }
22252239}
22262240
2227static void gx894pwbba_init( running_machine &machine, void (*output_callback_func)( running_machine &machine, int offset, int data ) )
2241void ksys573_state::gx894pwbba_init( void (ksys573_state::*output_callback_func)( int offset, int data ) )
22282242{
2229   ksys573_state *state = machine.driver_data<ksys573_state>();
22302243   int gx894_ram_size = 24 * 1024 * 1024;
22312244
2232   state->m_gx894pwbba_output_callback = output_callback_func;
2245   m_gx894pwbba_output_callback = output_callback_func;
22332246
2234   machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x1f640000, 0x1f6400ff, read32_delegate(FUNC(ksys573_state::gx894pwbba_r),state), write32_delegate(FUNC(ksys573_state::gx894pwbba_w),state));
2247   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x1f640000, 0x1f6400ff, read32_delegate(FUNC(ksys573_state::gx894pwbba_r),this), write32_delegate(FUNC(ksys573_state::gx894pwbba_w),this));
22352248
2236   state->m_gx894_ram_write_offset = 0;
2237   state->m_gx894_ram_read_offset = 0;
2238   state->m_gx894_ram = auto_alloc_array( machine, UINT16, gx894_ram_size/2 );
2249   m_gx894_ram_write_offset = 0;
2250   m_gx894_ram_read_offset = 0;
2251   m_gx894_ram = auto_alloc_array( machine(), UINT16, gx894_ram_size/2 );
22392252
2240   state->save_item( NAME(state->m_gx894pwbba_output_data) );
2241   state->save_pointer( NAME(state->m_gx894_ram), gx894_ram_size / 4 );
2253   save_item( NAME(m_gx894pwbba_output_data) );
2254   save_pointer( NAME(m_gx894_ram), gx894_ram_size / 4 );
22422255}
22432256
22442257/* ddr digital */
r21058r21059
22472260{
22482261   DRIVER_INIT_CALL(konami573);
22492262
2250   gx894pwbba_init( machine(), gn845pwbb_output_callback );
2263   gx894pwbba_init( &ksys573_state::gn845pwbb_output_callback );
22512264}
22522265
22532266/* guitar freaks digital */
r21058r21059
22562269{
22572270   DRIVER_INIT_CALL(konami573);
22582271
2259   gx894pwbba_init( machine(), NULL );
2272   gx894pwbba_init( NULL );
22602273   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler( 0x1f600000, 0x1f6000ff, read32_delegate(FUNC(ksys573_state::gtrfrks_io_r),this), write32_delegate(FUNC(ksys573_state::gtrfrks_io_w),this) );
22612274}
22622275
22632276/* ddr solo */
22642277
2265static void ddrsolo_output_callback( running_machine &machine, int offset, int data )
2278void ksys573_state::ddrsolo_output_callback( int offset, int data )
22662279{
22672280   switch( offset )
22682281   {
r21058r21059
23192332{
23202333   DRIVER_INIT_CALL(konami573);
23212334
2322   gx894pwbba_init( machine(), ddrsolo_output_callback );
2335   gx894pwbba_init( &ksys573_state::ddrsolo_output_callback );
23232336}
23242337
23252338/* drummania */
23262339
2327static void drmn_output_callback( running_machine &machine, int offset, int data )
2340void ksys573_state::drmn_output_callback( int offset, int data )
23282341{
23292342   switch( offset )
23302343   {
r21058r21059
23922405{
23932406   DRIVER_INIT_CALL(konami573);
23942407
2395   gx700pwfbf_init( machine(), drmn_output_callback );
2408   gx700pwfbf_init( &ksys573_state::drmn_output_callback );
23962409}
23972410
23982411DRIVER_INIT_MEMBER(ksys573_state,drmndigital)
23992412{
24002413   DRIVER_INIT_CALL(konami573);
24012414
2402   gx894pwbba_init( machine(), drmn_output_callback );
2415   gx894pwbba_init( &ksys573_state::drmn_output_callback );
24032416}
24042417
24052418/* dance maniax */
24062419
2407static void dmx_output_callback( running_machine &machine, int offset, int data )
2420void ksys573_state::dmx_output_callback( int offset, int data )
24082421{
24092422   switch( offset )
24102423   {
r21058r21059
25242537
25252538WRITE32_MEMBER(ksys573_state::dmx_io_w)
25262539{
2527   verboselog( machine(), 2, "dmx_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
2540   verboselog(2, "dmx_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
25282541
25292542   switch( offset )
25302543   {
r21058r21059
25392552      break;
25402553
25412554   default:
2542      verboselog( machine(), 0, "dmx_io_w: unhandled offset %08x, %08x\n", offset, mem_mask );
2555      verboselog(0, "dmx_io_w: unhandled offset %08x, %08x\n", offset, mem_mask );
25432556      break;
25442557   }
25452558}
r21058r21059
25482561{
25492562   DRIVER_INIT_CALL(konami573);
25502563
2551   gx894pwbba_init( machine(), dmx_output_callback );
2564   gx894pwbba_init( &ksys573_state::dmx_output_callback );
25522565   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1f600000, 0x1f6000ff, write32_delegate(FUNC(ksys573_state::dmx_io_w),this) );
25532566}
25542567
25552568/* salary man champ */
25562569
2557static void salarymc_lamp_callback( running_machine &machine, int data )
2570void ksys573_state::salarymc_lamp_callback( int data )
25582571{
2559   ksys573_state *state = machine.driver_data<ksys573_state>();
25602572   int d = ( data >> 7 ) & 1;
25612573   int rst = ( data >> 6 ) & 1;
25622574   int clk = ( data >> 5 ) & 1;
25632575
25642576   if( rst )
25652577   {
2566      state->m_salarymc_lamp_bits = 0;
2567      state->m_salarymc_lamp_shift = 0;
2578      m_salarymc_lamp_bits = 0;
2579      m_salarymc_lamp_shift = 0;
25682580   }
25692581
2570   if( state->m_salarymc_lamp_clk != clk )
2582   if( m_salarymc_lamp_clk != clk )
25712583   {
2572      state->m_salarymc_lamp_clk = clk;
2584      m_salarymc_lamp_clk = clk;
25732585
2574      if( state->m_salarymc_lamp_clk )
2586      if( m_salarymc_lamp_clk )
25752587      {
2576         state->m_salarymc_lamp_shift <<= 1;
2588         m_salarymc_lamp_shift <<= 1;
25772589
2578         state->m_salarymc_lamp_shift |= d;
2590         m_salarymc_lamp_shift |= d;
25792591
2580         state->m_salarymc_lamp_bits++;
2581         if( state->m_salarymc_lamp_bits == 16 )
2592         m_salarymc_lamp_bits++;
2593         if( m_salarymc_lamp_bits == 16 )
25822594         {
2583            if( ( state->m_salarymc_lamp_shift & ~0xe38 ) != 0 )
2595            if( ( m_salarymc_lamp_shift & ~0xe38 ) != 0 )
25842596            {
2585               verboselog( machine, 0, "unknown bits in salarymc_lamp_shift %08x\n", state->m_salarymc_lamp_shift & ~0xe38 );
2597               verboselog( 0, "unknown bits in salarymc_lamp_shift %08x\n", m_salarymc_lamp_shift & ~0xe38 );
25862598            }
25872599
2588            output_set_value( "player 1 red", ( state->m_salarymc_lamp_shift >> 11 ) & 1 );
2589            output_set_value( "player 1 green", ( state->m_salarymc_lamp_shift >> 10 ) & 1 );
2590            output_set_value( "player 1 blue", ( state->m_salarymc_lamp_shift >> 9 ) & 1 );
2600            output_set_value( "player 1 red", ( m_salarymc_lamp_shift >> 11 ) & 1 );
2601            output_set_value( "player 1 green", ( m_salarymc_lamp_shift >> 10 ) & 1 );
2602            output_set_value( "player 1 blue", ( m_salarymc_lamp_shift >> 9 ) & 1 );
25912603
2592            output_set_value( "player 2 red", ( state->m_salarymc_lamp_shift >> 5 ) & 1 );
2593            output_set_value( "player 2 green", ( state->m_salarymc_lamp_shift >> 4 ) & 1 );
2594            output_set_value( "player 2 blue", ( state->m_salarymc_lamp_shift >> 3 ) & 1 );
2604            output_set_value( "player 2 red", ( m_salarymc_lamp_shift >> 5 ) & 1 );
2605            output_set_value( "player 2 green", ( m_salarymc_lamp_shift >> 4 ) & 1 );
2606            output_set_value( "player 2 blue", ( m_salarymc_lamp_shift >> 3 ) & 1 );
25952607
2596            state->m_salarymc_lamp_bits = 0;
2597            state->m_salarymc_lamp_shift = 0;
2608            m_salarymc_lamp_bits = 0;
2609            m_salarymc_lamp_shift = 0;
25982610         }
25992611      }
26002612   }
r21058r21059
26042616{
26052617   DRIVER_INIT_CALL(konami573);
26062618
2607   m_security_callback = salarymc_lamp_callback;
2619   m_security_callback = &ksys573_state::salarymc_lamp_callback;
26082620
26092621   save_item( NAME(m_salarymc_lamp_bits) );
26102622   save_item( NAME(m_salarymc_lamp_shift) );
r21058r21059
26132625
26142626/* Hyper Bishi Bashi Champ */
26152627
2616static void hyperbbc_lamp_callback( running_machine &machine, int data )
2628void ksys573_state::hyperbbc_lamp_callback( int data )
26172629{
2618   ksys573_state *state = machine.driver_data<ksys573_state>();
26192630   int red = ( data >> 6 ) & 1;
26202631   int blue = ( data >> 5 ) & 1;
26212632   int green = ( data >> 4 ) & 1;
26222633   int strobe1 = ( data >> 3 ) & 1;
26232634   int strobe2 = ( data >> 0 ) & 1;
26242635
2625   if( strobe1 && !state->m_hyperbbc_lamp_strobe1 )
2636   if( strobe1 && !m_hyperbbc_lamp_strobe1 )
26262637   {
26272638      output_set_value( "player 1 red", red );
26282639      output_set_value( "player 1 green", green );
26292640      output_set_value( "player 1 blue", blue );
26302641   }
26312642
2632   state->m_hyperbbc_lamp_strobe1 = strobe1;
2643   m_hyperbbc_lamp_strobe1 = strobe1;
26332644
2634   if( strobe2 && !state->m_hyperbbc_lamp_strobe2 )
2645   if( strobe2 && !m_hyperbbc_lamp_strobe2 )
26352646   {
26362647      output_set_value( "player 2 red", red );
26372648      output_set_value( "player 2 green", green );
26382649      output_set_value( "player 2 blue", blue );
26392650   }
26402651
2641   state->m_hyperbbc_lamp_strobe2 = strobe2;
2652   m_hyperbbc_lamp_strobe2 = strobe2;
26422653}
26432654
26442655DRIVER_INIT_MEMBER(ksys573_state,hyperbbc)
26452656{
26462657   DRIVER_INIT_CALL(konami573);
26472658
2648   m_security_callback = hyperbbc_lamp_callback;
2659   m_security_callback = &ksys573_state::hyperbbc_lamp_callback;
26492660
26502661   save_item( NAME(m_hyperbbc_lamp_strobe1) );
26512662   save_item( NAME(m_hyperbbc_lamp_strobe2) );
r21058r21059
26532664
26542665/* Mambo A Go Go */
26552666
2656static void mamboagg_output_callback( running_machine &machine, int offset, int data )
2667void ksys573_state::mamboagg_output_callback( int offset, int data )
26572668{
26582669   switch( offset )
26592670   {
r21058r21059
26832694
26842695WRITE32_MEMBER(ksys573_state::mamboagg_io_w)
26852696{
2686   verboselog( machine(), 2, "mamboagg_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
2697   verboselog(2, "mamboagg_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
26872698
26882699   switch( offset )
26892700   {
r21058r21059
26942705      break;
26952706
26962707   default:
2697      verboselog( machine(), 0, "mamboagg_io_w: unhandled offset %08x, %08x\n", offset, mem_mask );
2708      verboselog(0, "mamboagg_io_w: unhandled offset %08x, %08x\n", offset, mem_mask );
26982709      break;
26992710   }
27002711}
r21058r21059
27032714{
27042715   DRIVER_INIT_CALL(konami573);
27052716
2706   gx894pwbba_init( machine(), mamboagg_output_callback );
2717   gx894pwbba_init( &ksys573_state::mamboagg_output_callback );
27072718   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1f600000, 0x1f6000ff, write32_delegate(FUNC(ksys573_state::mamboagg_io_w),this));
27082719}
27092720
r21058r21059
27482759
27492760int pad_light[ 6 ];
27502761
2751static void punchmania_output_callback( running_machine &machine, int offset, int data )
2762void ksys573_state::punchmania_output_callback( int offset, int data )
27522763{
2753   ksys573_state *state = machine.driver_data<ksys573_state>();
2754   double *pad_position = state->m_pad_position;
2764   double *pad_position = m_pad_position;
27552765   char pad[ 7 ];
27562766
27572767   switch( offset )
r21058r21059
28812891{
28822892   DRIVER_INIT_CALL(konami573);
28832893
2884   gx700pwfbf_init( machine(), punchmania_output_callback );
2894   gx700pwfbf_init( &ksys573_state::punchmania_output_callback );
28852895}
28862896
28872897/* GunMania */
r21058r21059
29742984      break;
29752985   }
29762986
2977   verboselog( machine(), 2, "gunmania_w %08x %08x %08x\n", offset, mem_mask, data );
2987   verboselog(2, "gunmania_w %08x %08x %08x\n", offset, mem_mask, data );
29782988}
29792989
29802990CUSTOM_INPUT_MEMBER(ksys573_state::gunmania_tank_shutter_sensor)
r21058r21059
30133023      break;
30143024   }
30153025
3016   verboselog( machine(), 2, "gunmania_r %08x %08x %08x\n", offset, mem_mask, data );
3026   verboselog(2, "gunmania_r %08x %08x %08x\n", offset, mem_mask, data );
30173027   return data;
30183028}
30193029
r21058r21059
30553065   MCFG_CPU_ADD( "maincpu", CXD8530CQ, XTAL_67_7376MHz )
30563066   MCFG_CPU_PROGRAM_MAP( konami573_map )
30573067
3058   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 5, psx_dma_read_delegate( FUNC( cdrom_dma_read ), (ksys573_state *) owner ) )
3059   MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 5, psx_dma_write_delegate( FUNC( cdrom_dma_write ), (ksys573_state *) owner ) )
3068   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 5, psx_dma_read_delegate( FUNC( ksys573_state::cdrom_dma_read ), (ksys573_state *) owner ) )
3069   MCFG_PSX_DMA_CHANNEL_WRITE( "maincpu", 5, psx_dma_write_delegate( FUNC( ksys573_state::cdrom_dma_write ), (ksys573_state *) owner ) )
30603070
30613071   MCFG_MACHINE_RESET_OVERRIDE(ksys573_state, konami573 )
30623072
r21058r21059
30743084
30753085   /* video hardware */
30763086   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0x200000, XTAL_53_693175MHz )
3077   MCFG_PSXGPU_VBLANK_CALLBACK( vblank_state_delegate( FUNC( sys573_vblank ), (ksys573_state *) owner ) )
3087   MCFG_PSXGPU_VBLANK_CALLBACK( vblank_state_delegate( FUNC( ksys573_state::sys573_vblank ), (ksys573_state *) owner ) )
30783088
30793089   /* sound hardware */
30803090   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
trunk/src/mame/drivers/taitogn.c
r21058r21059
393393   DECLARE_DRIVER_INIT(coh3002t_mp);
394394   DECLARE_DRIVER_INIT(coh3002t);
395395   DECLARE_MACHINE_RESET(coh3002t);
396   void rf5c296_reg_w(ATTR_UNUSED UINT8 reg, UINT8 data);
397   UINT8 rf5c296_reg_r(ATTR_UNUSED UINT8 reg);
398   UINT32 gen_flash_r(intelfsh16_device *device, offs_t offset, UINT32 mem_mask);
399   void gen_flash_w(intelfsh16_device *device, offs_t offset, UINT32 data, UINT32 mem_mask);
400   void install_handlers(int mode);
396401};
397402
398403
399404// rf5c296 is very inaccurate at that point, it hardcodes the gnet config
400405
401static void rf5c296_reg_w(ATTR_UNUSED running_machine &machine, UINT8 reg, UINT8 data)
406void taitogn_state::rf5c296_reg_w(ATTR_UNUSED UINT8 reg, UINT8 data)
402407{
403   taitogn_state *state = machine.driver_data<taitogn_state>();
404   //  fprintf(stderr, "rf5c296_reg_w %02x, %02x (%s)\n", reg, data, machine.describe_context());
408   //  fprintf(stderr, "rf5c296_reg_w %02x, %02x (%s)\n", reg, data, machine().describe_context());
405409   switch (reg)
406410   {
407411      // Interrupt and General Control Register
r21058r21059
409413         // Check for card reset
410414         if (!(data & 0x40))
411415         {
412            ide_controller_device *card = (ide_controller_device *) machine.device(":card");
416            ide_controller_device *card = (ide_controller_device *) machine().device(":card");
413417
414418            card->reset();
415            state->m_locked = 0x1ff;
419            m_locked = 0x1ff;
416420            card->ide_set_gnet_readlock(1);
417421         }
418422      break;
r21058r21059
422426   }
423427}
424428
425static UINT8 rf5c296_reg_r(ATTR_UNUSED running_machine &machine, UINT8 reg)
429UINT8 taitogn_state::rf5c296_reg_r(ATTR_UNUSED UINT8 reg)
426430{
427   //  fprintf(stderr, "rf5c296_reg_r %02x (%s)\n", reg, machine.describe_context());
431   //  fprintf(stderr, "rf5c296_reg_r %02x (%s)\n", reg, machine().describe_context());
428432   return 0x00;
429433}
430434
r21058r21059
439443      if(ACCESSING_BITS_0_7)
440444         m_rf5c296_reg = data;
441445      if(ACCESSING_BITS_8_15)
442         rf5c296_reg_w(machine(), m_rf5c296_reg, data >> 8);
446         rf5c296_reg_w(m_rf5c296_reg, data >> 8);
443447   }
444448}
445449
r21058r21059
455459      if(ACCESSING_BITS_0_7)
456460         res |= m_rf5c296_reg;
457461      if(ACCESSING_BITS_8_15)
458         res |= rf5c296_reg_r(machine(), m_rf5c296_reg) << 8;
462         res |= rf5c296_reg_r(m_rf5c296_reg) << 8;
459463      return res;
460464   }
461465
r21058r21059
507511
508512// Flash handling
509513
510static UINT32 gen_flash_r(intelfsh16_device *device, offs_t offset, UINT32 mem_mask)
514UINT32 taitogn_state::gen_flash_r(intelfsh16_device *device, offs_t offset, UINT32 mem_mask)
511515{
512516   UINT32 res = 0;
513517   offset *= 2;
r21058r21059
518522   return res;
519523}
520524
521static void gen_flash_w(intelfsh16_device *device, offs_t offset, UINT32 data, UINT32 mem_mask)
525void taitogn_state::gen_flash_w(intelfsh16_device *device, offs_t offset, UINT32 data, UINT32 mem_mask)
522526{
523527   offset *= 2;
524528   if(ACCESSING_BITS_0_15)
r21058r21059
578582   gen_flash_w(m_sndflash[2], offset, data, mem_mask);
579583}
580584
581static void install_handlers(running_machine &machine, int mode)
585void taitogn_state::install_handlers(int mode)
582586{
583   taitogn_state *state = machine.driver_data<taitogn_state>();
584   address_space &a = machine.device("maincpu")->memory().space(AS_PROGRAM);
587   address_space &a = machine().device("maincpu")->memory().space(AS_PROGRAM);
585588   if(mode == 0) {
586589      // Mode 0 has access to the subbios, the mn102 flash and the rf5c296 mem zone
587      a.install_readwrite_handler(0x1f000000, 0x1f1fffff, read32_delegate(FUNC(taitogn_state::flash_subbios_r),state), write32_delegate(FUNC(taitogn_state::flash_subbios_w),state));
588      a.install_readwrite_handler(0x1f200000, 0x1f2fffff, read32_delegate(FUNC(taitogn_state::rf5c296_mem_r),state), write32_delegate(FUNC(taitogn_state::rf5c296_mem_w),state));
589      a.install_readwrite_handler(0x1f300000, 0x1f37ffff, read32_delegate(FUNC(taitogn_state::flash_mn102_r),state), write32_delegate(FUNC(taitogn_state::flash_mn102_w),state));
590      a.install_readwrite_handler(0x1f000000, 0x1f1fffff, read32_delegate(FUNC(taitogn_state::flash_subbios_r),this), write32_delegate(FUNC(taitogn_state::flash_subbios_w),this));
591      a.install_readwrite_handler(0x1f200000, 0x1f2fffff, read32_delegate(FUNC(taitogn_state::rf5c296_mem_r),this), write32_delegate(FUNC(taitogn_state::rf5c296_mem_w),this));
592      a.install_readwrite_handler(0x1f300000, 0x1f37ffff, read32_delegate(FUNC(taitogn_state::flash_mn102_r),this), write32_delegate(FUNC(taitogn_state::flash_mn102_w),this));
590593      a.nop_readwrite(0x1f380000, 0x1f5fffff);
591594
592595   } else {
593596      // Mode 1 has access to the 3 samples flashes
594      a.install_readwrite_handler(0x1f000000, 0x1f1fffff, read32_delegate(FUNC(taitogn_state::flash_s1_r),state), write32_delegate(FUNC(taitogn_state::flash_s1_w),state));
595      a.install_readwrite_handler(0x1f200000, 0x1f3fffff, read32_delegate(FUNC(taitogn_state::flash_s2_r),state), write32_delegate(FUNC(taitogn_state::flash_s2_w),state));
596      a.install_readwrite_handler(0x1f400000, 0x1f5fffff, read32_delegate(FUNC(taitogn_state::flash_s3_r),state), write32_delegate(FUNC(taitogn_state::flash_s3_w),state));
597      a.install_readwrite_handler(0x1f000000, 0x1f1fffff, read32_delegate(FUNC(taitogn_state::flash_s1_r),this), write32_delegate(FUNC(taitogn_state::flash_s1_w),this));
598      a.install_readwrite_handler(0x1f200000, 0x1f3fffff, read32_delegate(FUNC(taitogn_state::flash_s2_r),this), write32_delegate(FUNC(taitogn_state::flash_s2_w),this));
599      a.install_readwrite_handler(0x1f400000, 0x1f5fffff, read32_delegate(FUNC(taitogn_state::flash_s3_r),this), write32_delegate(FUNC(taitogn_state::flash_s3_w),this));
597600   }
598601}
599602
r21058r21059
634637#endif
635638
636639   if((p ^ m_control) & 0x04)
637      install_handlers(machine(), m_control & 4 ? 1 : 0);
640      install_handlers(m_control & 4 ? 1 : 0);
638641}
639642
640643WRITE32_MEMBER(taitogn_state::control2_w)
r21058r21059
785788MACHINE_RESET_MEMBER(taitogn_state,coh3002t)
786789{
787790   m_locked = 0x1ff;
788   install_handlers(machine(), 0);
791   install_handlers(0);
789792   m_control = 0;
790793
791794   ide_controller_device *card = (ide_controller_device *) machine().device(":card");
trunk/src/mame/drivers/nightgal.c
r21058r21059
127127   required_ioport m_io_dswc;
128128
129129   UINT8 nightgal_gfx_nibble( int niboffset );
130   void plot_nightgal_gfx_pixel( UINT8 pix, int x, int y );
130131};
131132
132133
r21058r21059
176177   }
177178}
178179
179static void plot_nightgal_gfx_pixel( running_machine &machine, UINT8 pix, int x, int y )
180void nightgal_state::plot_nightgal_gfx_pixel( UINT8 pix, int x, int y )
180181{
181   nightgal_state *state = machine.driver_data<nightgal_state>();
182182   if (y >= 512) return;
183183   if (x >= 512) return;
184184   if (y < 0) return;
185185   if (x < 0) return;
186186
187187   if (x & 1)
188      state->m_blit_buffer[(y * 256) + (x >> 1)] = (state->m_blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
188      m_blit_buffer[(y * 256) + (x >> 1)] = (m_blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
189189   else
190      state->m_blit_buffer[(y * 256) + (x >> 1)] = (state->m_blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
190      m_blit_buffer[(y * 256) + (x >> 1)] = (m_blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
191191}
192192
193193WRITE8_MEMBER(nightgal_state::nsc_true_blitter_w)
r21058r21059
231231               dat = cur_pen_lo | (cur_pen_hi << 4);
232232
233233               if ((dat & 0xff) != 0)
234                  plot_nightgal_gfx_pixel(machine(), dat, drawx, drawy);
234                  plot_nightgal_gfx_pixel(dat, drawx, drawy);
235235
236236               if (!flipx)
237237                  count--;
r21058r21059
286286               dat = cur_pen_lo | cur_pen_hi << 4;
287287
288288               if ((dat & 0xff) != 0)
289                  plot_nightgal_gfx_pixel(machine(), dat, drawx, drawy);
289                  plot_nightgal_gfx_pixel(dat, drawx, drawy);
290290
291291               if (!flipx)
292292                  count--;
trunk/src/mame/drivers/nmg5.c
r21058r21059
279279   virtual void machine_reset();
280280   virtual void video_start();
281281   UINT32 screen_update_nmg5(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
282   void draw_bitmap( bitmap_ind16 &bitmap );
282283};
283284
284285
r21058r21059
854855
855856
856857
857static void draw_bitmap( running_machine &machine, bitmap_ind16 &bitmap )
858void nmg5_state::draw_bitmap( bitmap_ind16 &bitmap )
858859{
859   nmg5_state *state = machine.driver_data<nmg5_state>();
860860   int yyy = 256;
861861   int xxx = 512 / 4;
862862   UINT16 x, y, count;
r21058r21059
869869   {
870870      for (x = 0; x < xxx; x++)
871871      {
872         pix = (state->m_bitmap[count] & 0xf000) >> 12;
872         pix = (m_bitmap[count] & 0xf000) >> 12;
873873         if (pix) bitmap.pix16(y + yoff, x * 4 + 0 + xoff) = pix + 0x300;
874         pix = (state->m_bitmap[count] & 0x0f00) >> 8;
874         pix = (m_bitmap[count] & 0x0f00) >> 8;
875875         if (pix) bitmap.pix16(y + yoff, x * 4 + 1 + xoff) = pix + 0x300;
876         pix = (state->m_bitmap[count] & 0x00f0) >> 4;
876         pix = (m_bitmap[count] & 0x00f0) >> 4;
877877         if (pix) bitmap.pix16(y + yoff, x * 4 + 2 + xoff) = pix + 0x300;
878         pix = (state->m_bitmap[count] & 0x000f) >> 0;
878         pix = (m_bitmap[count] & 0x000f) >> 0;
879879         if (pix) bitmap.pix16(y + yoff, x * 4 + 3 + xoff) = pix + 0x300;
880880
881881         count++;
r21058r21059
897897   {
898898      m_sprgen->draw_sprites(bitmap, cliprect, m_spriteram, 0x400);
899899      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
900      draw_bitmap(machine(), bitmap);
900      draw_bitmap(bitmap);
901901   }
902902   else if (m_priority_reg == 1)
903903   {
904      draw_bitmap(machine(), bitmap);
904      draw_bitmap(bitmap);
905905      m_sprgen->draw_sprites(bitmap, cliprect, m_spriteram, 0x400);
906906      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
907907   }
908908   else if (m_priority_reg == 2)
909909   {
910910      m_sprgen->draw_sprites(bitmap, cliprect, m_spriteram, 0x400);
911      draw_bitmap(machine(), bitmap);
911      draw_bitmap(bitmap);
912912      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
913913   }
914914   else if (m_priority_reg == 3)
915915   {
916916      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
917917      m_sprgen->draw_sprites(bitmap, cliprect, m_spriteram, 0x400);
918      draw_bitmap(machine(), bitmap);
918      draw_bitmap(bitmap);
919919   }
920920   else if (m_priority_reg == 7)
921921   {
922922      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
923      draw_bitmap(machine(), bitmap);
923      draw_bitmap(bitmap);
924924      m_sprgen->draw_sprites(bitmap, cliprect, m_spriteram, 0x400);
925925   }
926926   return 0;
trunk/src/mame/drivers/namcos23.c
r21058r21059
14861486   UINT32 screen_update_s23(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
14871487   INTERRUPT_GEN_MEMBER(s23_interrupt);
14881488   TIMER_CALLBACK_MEMBER(c361_timer_cb);
1489   UINT8 nthbyte(const UINT32 *pSource, int offs);
1490   UINT16 nthword(const UINT32 *pSource, int offs);
1491   inline INT32 u32_to_s24(UINT32 v);
1492   inline INT32 u32_to_s10(UINT32 v);
1493   INT32 *p3d_getv(UINT16 id);
1494   INT16 *p3d_getm(UINT16 id);
1495   void p3d_matrix_set(const UINT16 *p, int size);
1496   void p3d_vector_set(const UINT16 *p, int size);
1497   void p3d_scaling_set(const UINT16 *p, int size);
1498   void p3d_vector_matrix_mul(const UINT16 *p, int size);
1499   void p3d_matrix_vector_mul(const UINT16 *p, int size);
1500   void p3d_matrix_matrix_mul(const UINT16 *p, int size);
1501   void p3d_render(const UINT16 *p, int size, bool use_scaling);
1502   void p3d_flush(const UINT16 *p, int size);
1503   void p3d_dma(address_space &space, UINT32 adr, UINT32 size);
1504   void render_apply_transform(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, poly_vertex &pv);
1505   void render_apply_matrot(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, INT32 &x, INT32 &y, INT32 &z);
1506   void render_project(poly_vertex &pv);
1507   void render_one_model(const namcos23_render_entry *re);
1508   void render_flush(bitmap_rgb32 &bitmap);
1509   void render_run(bitmap_rgb32 &bitmap);
14891510};
14901511
14911512
1492static UINT8 nthbyte(const UINT32 *pSource, int offs)
1513UINT8 namcos23_state::nthbyte(const UINT32 *pSource, int offs)
14931514{
14941515   pSource += offs/4;
14951516   return (pSource[0]<<((offs&3)*8))>>24;
14961517}
14971518
1498static UINT16 nthword(const UINT32 *pSource, int offs)
1519UINT16 namcos23_state::nthword(const UINT32 *pSource, int offs)
14991520{
15001521   pSource += offs/2;
15011522   return (pSource[0]<<((offs&1)*16))>>16;
r21058r21059
15131534
15141535// 3D hardware, to throw at least in part in video/namcos23.c
15151536
1516INLINE INT32 u32_to_s24(UINT32 v)
1537inline INT32 namcos23_state::u32_to_s24(UINT32 v)
15171538{
15181539   return v & 0x800000 ? v | 0xff000000 : v & 0xffffff;
15191540}
15201541
1521INLINE INT32 u32_to_s10(UINT32 v)
1542inline INT32 namcos23_state::u32_to_s10(UINT32 v)
15221543{
15231544   return v & 0x200 ? v | 0xfffffe00 : v & 0x1ff;
15241545}
r21058r21059
15331554   return UINT8(l);
15341555}
15351556
1536static INT32 *p3d_getv(namcos23_state *state, UINT16 id)
1557INT32 *namcos23_state::p3d_getv(UINT16 id)
15371558{
15381559   if(id == 0x8000)
1539      return state->m_light_vector;
1560      return m_light_vector;
15401561   if(id >= 0x100)
15411562   {
1542      memset(state->m_spv, 0, sizeof(state->m_spv));
1543      return state->m_spv;
1563      memset(m_spv, 0, sizeof(m_spv));
1564      return m_spv;
15441565   }
1545   return state->m_vectors[id];
1566   return m_vectors[id];
15461567}
15471568
1548static INT16 *p3d_getm(namcos23_state *state, UINT16 id)
1569INT16 *namcos23_state::p3d_getm(UINT16 id)
15491570{
15501571   if(id >= 0x100)
15511572   {
1552      memset(state->m_spm, 0, sizeof(state->m_spm));
1553      return state->m_spm;
1573      memset(m_spm, 0, sizeof(m_spm));
1574      return m_spm;
15541575   }
1555   return state->m_matrices[id];
1576   return m_matrices[id];
15561577}
15571578
1558static void p3d_matrix_set(namcos23_state *state, const UINT16 *p, int size)
1579void namcos23_state::p3d_matrix_set(const UINT16 *p, int size)
15591580{
15601581   if(size != 10)
15611582   {
15621583      logerror("WARNING: p3d_matrix_set with size %d\n", size);
15631584      return;
15641585   }
1565   INT16 *t = p3d_getm(state, *p++);
1586   INT16 *t = p3d_getm(*p++);
15661587   for(int i=0; i<9; i++)
15671588      t[i] = *p++;
15681589}
15691590
1570static void p3d_vector_set(namcos23_state *state, const UINT16 *p, int size)
1591void namcos23_state::p3d_vector_set(const UINT16 *p, int size)
15711592{
15721593   if(size != 7)
15731594   {
15741595      logerror("WARNING: p3d_vector_set with size %d\n", size);
15751596      return;
15761597   }
1577   INT32 *t = p3d_getv(state, *p++);
1598   INT32 *t = p3d_getv(*p++);
15781599   for(int i=0; i<3; i++)
15791600   {
15801601      t[i] = u32_to_s24((p[0] << 16) | p[1]);
r21058r21059
15831604}
15841605
15851606
1586static void p3d_scaling_set(namcos23_state *state, const UINT16 *p, int size)
1607void namcos23_state::p3d_scaling_set(const UINT16 *p, int size)
15871608{
15881609   if(size != 1)
15891610   {
15901611      logerror("WARNING: p3d_scaling_set with size %d\n", size);
15911612      return;
15921613   }
1593   state->m_scaling = *p;
1614   m_scaling = *p;
15941615}
15951616
1596static void p3d_vector_matrix_mul(namcos23_state *state, const UINT16 *p, int size)
1617void namcos23_state::p3d_vector_matrix_mul(const UINT16 *p, int size)
15971618{
15981619   if(size != 4)
15991620   {
r21058r21059
16031624   if(p[2] != 0xffff)
16041625      logerror("WARNING: p3d_vector_matrix_mul with +2=%04x\n", p[2]);
16051626
1606   INT32 *t       = p3d_getv(state, p[0]);
1607   const INT16 *m = p3d_getm(state, p[1]);
1608   const INT32 *v = p3d_getv(state, p[3]);
1627   INT32 *t       = p3d_getv(p[0]);
1628   const INT16 *m = p3d_getm(p[1]);
1629   const INT32 *v = p3d_getv(p[3]);
16091630
16101631   t[0] = INT32((m[0]*INT64(v[0]) + m[3]*INT64(v[1]) + m[6]*INT64(v[2])) >> 14);
16111632   t[1] = INT32((m[1]*INT64(v[0]) + m[4]*INT64(v[1]) + m[7]*INT64(v[2])) >> 14);
16121633   t[2] = INT32((m[2]*INT64(v[0]) + m[5]*INT64(v[1]) + m[8]*INT64(v[2])) >> 14);
16131634}
16141635
1615static void p3d_matrix_vector_mul(namcos23_state *state, const UINT16 *p, int size)
1636void namcos23_state::p3d_matrix_vector_mul(const UINT16 *p, int size)
16161637{
16171638   if(size != 4)
16181639   {
r21058r21059
16221643   if(p[2] != 0xffff)
16231644      logerror("WARNING: p3d_matrix_vector_mul with +2=%04x\n", p[2]);
16241645
1625   INT32 *t       = p3d_getv(state, p[0]);
1626   const INT16 *m = p3d_getm(state, p[1]);
1627   const INT32 *v = p3d_getv(state, p[3]);
1646   INT32 *t       = p3d_getv(p[0]);
1647   const INT16 *m = p3d_getm(p[1]);
1648   const INT32 *v = p3d_getv(p[3]);
16281649
16291650   t[0] = INT32((m[0]*INT64(v[0]) + m[1]*INT64(v[1]) + m[2]*INT64(v[2])) >> 14);
16301651   t[1] = INT32((m[3]*INT64(v[0]) + m[4]*INT64(v[1]) + m[7]*INT64(v[2])) >> 14);
r21058r21059
16321653}
16331654
16341655
1635static void p3d_matrix_matrix_mul(namcos23_state *state, const UINT16 *p, int size)
1656void namcos23_state::p3d_matrix_matrix_mul(const UINT16 *p, int size)
16361657{
16371658   if(size != 4)
16381659   {
r21058r21059
16421663   if(p[2] != 0xffff)
16431664      logerror("WARNING: p3d_matrix_matrix_mul with +2=%04x\n", p[2]);
16441665
1645   INT16 *t        = p3d_getm(state, p[0]);
1646   const INT16 *m1 = p3d_getm(state, p[1]);
1647   const INT16 *m2 = p3d_getm(state, p[3]);
1666   INT16 *t        = p3d_getm(p[0]);
1667   const INT16 *m1 = p3d_getm(p[1]);
1668   const INT16 *m2 = p3d_getm(p[3]);
16481669
16491670   t[0] = INT16((m1[0]*m2[0] + m1[1]*m2[3] + m1[2]*m2[6]) >> 14);
16501671   t[1] = INT16((m1[0]*m2[1] + m1[1]*m2[4] + m1[2]*m2[7]) >> 14);
r21058r21059
16581679}
16591680
16601681
1661static void p3d_render(namcos23_state *state, const UINT16 *p, int size, bool use_scaling)
1682void namcos23_state::p3d_render(const UINT16 *p, int size, bool use_scaling)
16621683{
1663   render_t &render = state->m_render;
1684   render_t &render = m_render;
16641685
16651686   if(size != 3)
16661687   {
r21058r21059
16771698   }
16781699
16791700   // Vector and matrix may be inverted
1680   const INT16 *m = p3d_getm(state, p[1]);
1681   const INT32 *v = p3d_getv(state, p[2]);
1701   const INT16 *m = p3d_getm(p[1]);
1702   const INT32 *v = p3d_getv(p[2]);
16821703
16831704   namcos23_render_entry *re = render.entries[render.cur] + render.count[render.cur];
16841705   re->type = MODEL;
16851706   re->model.model = p[0];
1686   re->model.scaling = use_scaling ? state->m_scaling / 16384.0 : 1.0;
1707   re->model.scaling = use_scaling ? m_scaling / 16384.0 : 1.0;
16871708   memcpy(re->model.m, m, sizeof(re->model.m));
16881709   memcpy(re->model.v, v, sizeof(re->model.v));
16891710   if(0)
r21058r21059
16981719}
16991720
17001721
1701static void p3d_flush(namcos23_state *state, const UINT16 *p, int size)
1722void namcos23_state::p3d_flush(const UINT16 *p, int size)
17021723{
1703   render_t &render = state->m_render;
1724   render_t &render = m_render;
17041725
17051726   if(size != 0)
17061727   {
r21058r21059
17131734   render.count[render.cur]++;
17141735}
17151736
1716static void p3d_dma(address_space &space, UINT32 adr, UINT32 size)
1737void namcos23_state::p3d_dma(address_space &space, UINT32 adr, UINT32 size)
17171738{
1718   namcos23_state *state = space.machine().driver_data<namcos23_state>();
17191739   UINT16 buffer[256];
17201740   adr &= 0x1fffffff;
17211741   int pos = 0;
r21058r21059
17531773
17541774      switch(h1)
17551775      {
1756         case 0x0040: p3d_matrix_set(state, buffer, psize); break;
1757         case 0x0050: p3d_vector_set(state, buffer, psize); break;
1758         case 0x0000: p3d_matrix_matrix_mul(state, buffer, psize); break;
1759         case 0x0810: p3d_matrix_vector_mul(state, buffer, psize); break;
1760         case 0x1010: p3d_vector_matrix_mul(state, buffer, psize); break;
1761         case 0x4400: p3d_scaling_set(state, buffer, psize); break;
1762         case 0x8000: p3d_render(state, buffer, psize, false); break;
1763         case 0x8080: p3d_render(state, buffer, psize, true); break;
1764         case 0xc000: p3d_flush(state, buffer, psize); break;
1776         case 0x0040: p3d_matrix_set(buffer, psize); break;
1777         case 0x0050: p3d_vector_set(buffer, psize); break;
1778         case 0x0000: p3d_matrix_matrix_mul(buffer, psize); break;
1779         case 0x0810: p3d_matrix_vector_mul(buffer, psize); break;
1780         case 0x1010: p3d_vector_matrix_mul(buffer, psize); break;
1781         case 0x4400: p3d_scaling_set(buffer, psize); break;
1782         case 0x8000: p3d_render(buffer, psize, false); break;
1783         case 0x8080: p3d_render(buffer, psize, true); break;
1784         case 0xc000: p3d_flush(buffer, psize); break;
17651785         default:
17661786            if(0)
17671787            {
r21058r21059
18401860   }
18411861}
18421862
1843static void render_apply_transform(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, poly_vertex &pv)
1863void namcos23_state::render_apply_transform(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, poly_vertex &pv)
18441864{
18451865   pv.x =    (INT32((re->model.m[0]*INT64(xi) + re->model.m[3]*INT64(yi) + re->model.m[6]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[0])/16384.0;
18461866   pv.y =    (INT32((re->model.m[1]*INT64(xi) + re->model.m[4]*INT64(yi) + re->model.m[7]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[1])/16384.0;
18471867   pv.p[0] = (INT32((re->model.m[2]*INT64(xi) + re->model.m[5]*INT64(yi) + re->model.m[8]*INT64(zi)) >> 14)*re->model.scaling + re->model.v[2])/16384.0;
18481868}
18491869
1850static void render_apply_matrot(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, INT32 &x, INT32 &y, INT32 &z)
1870void namcos23_state::render_apply_matrot(INT32 xi, INT32 yi, INT32 zi, const namcos23_render_entry *re, INT32 &x, INT32 &y, INT32 &z)
18511871{
18521872   x = (re->model.m[0]*xi + re->model.m[3]*yi + re->model.m[6]*zi) >> 14;
18531873   y = (re->model.m[1]*xi + re->model.m[4]*yi + re->model.m[7]*zi) >> 14;
18541874   z = (re->model.m[2]*xi + re->model.m[5]*yi + re->model.m[8]*zi) >> 14;
18551875}
18561876
1857static void render_project(poly_vertex &pv)
1877void namcos23_state::render_project(poly_vertex &pv)
18581878{
18591879   // 768 validated by the title screen size on tc2:
18601880   // texture is 640x480, x range is 3.125, y range is 2.34375, z is 3.75
r21058r21059
18861906   return pens[color];
18871907}
18881908
1889static void render_one_model(running_machine &machine, const namcos23_render_entry *re)
1909void namcos23_state::render_one_model(const namcos23_render_entry *re)
18901910{
1891   namcos23_state *state = machine.driver_data<namcos23_state>();
1892   render_t &render = state->m_render;
1893   UINT32 adr = state->m_ptrom[re->model.model];
1894   if(adr >= state->m_ptrom_limit)
1911   render_t &render = m_render;
1912   UINT32 adr = m_ptrom[re->model.model];
1913   if(adr >= m_ptrom_limit)
18951914   {
18961915      logerror("WARNING: model %04x base address %08x out-of-bounds - pointram?\n", re->model.model, adr);
18971916      return;
18981917   }
18991918
1900   while(adr < state->m_ptrom_limit)
1919   while(adr < m_ptrom_limit)
19011920   {
19021921      poly_vertex pv[15];
19031922
1904      UINT32 type = state->m_ptrom[adr++];
1905      UINT32 h    = state->m_ptrom[adr++];
1923      UINT32 type = m_ptrom[adr++];
1924      UINT32 h    = m_ptrom[adr++];
19061925
19071926
19081927      float tbase = (type >> 24) << 12;
r21058r21059
19231942         adr += ne;
19241943      }
19251944      else
1926         light = state->m_ptrom[adr++];
1945         light = m_ptrom[adr++];
19271946
19281947      float minz = FLT_MAX;
19291948      float maxz = FLT_MIN;
19301949
19311950      for(int i=0; i<ne; i++)
19321951      {
1933         UINT32 v1 = state->m_ptrom[adr++];
1934         UINT32 v2 = state->m_ptrom[adr++];
1935         UINT32 v3 = state->m_ptrom[adr++];
1952         UINT32 v1 = m_ptrom[adr++];
1953         UINT32 v2 = m_ptrom[adr++];
1954         UINT32 v3 = m_ptrom[adr++];
19361955
19371956         render_apply_transform(u32_to_s24(v1), u32_to_s24(v2), u32_to_s24(v3), re, pv[i]);
19381957         pv[i].p[1] = (((v1 >> 20) & 0xf00) | ((v2 >> 24 & 0xff))) + 0.5;
r21058r21059
19531972            break;
19541973         case 3:
19551974         {
1956            UINT32 norm = state->m_ptrom[extptr++];
1975            UINT32 norm = m_ptrom[extptr++];
19571976            INT32 nx = u32_to_s10(norm >> 20);
19581977            INT32 ny = u32_to_s10(norm >> 10);
19591978            INT32 nz = u32_to_s10(norm);
19601979            INT32 nrx, nry, nrz;
19611980            render_apply_matrot(nx, ny, nz, re, nrx, nry, nrz);
19621981
1963            float lsi = float(nrx*state->m_light_vector[0] + nry*state->m_light_vector[1] + nrz*state->m_light_vector[2])/4194304.0;
1982            float lsi = float(nrx*m_light_vector[0] + nry*m_light_vector[1] + nrz*m_light_vector[2])/4194304.0;
19641983            if(lsi < 0)
19651984               lsi = 0;
19661985
r21058r21059
19872006         }
19882007         p->zkey = 0.5*(minz+maxz);
19892008         p->front = !(h & 0x00000001);
1990         p->rd.machine = &machine;
2009         p->rd.machine = &machine();
19912010         p->rd.texture_lookup = render_texture_lookup_nocache_point;
1992         p->rd.pens = machine.pens + (color << 8);
2011         p->rd.pens = machine().pens + (color << 8);
19932012         render.poly_count++;
19942013      }
19952014
r21058r21059
20092028   return p1->zkey < p2->zkey ? 1 : p1->zkey > p2->zkey ? -1 : 0;
20102029}
20112030
2012static void render_flush(running_machine &machine, bitmap_rgb32 &bitmap)
2031void namcos23_state::render_flush(bitmap_rgb32 &bitmap)
20132032{
2014   namcos23_state *state = machine.driver_data<namcos23_state>();
2015   render_t &render = state->m_render;
2033   render_t &render = m_render;
20162034
20172035   if(!render.poly_count)
20182036      return;
r21058r21059
20342052   render.poly_count = 0;
20352053}
20362054
2037static void render_run(running_machine &machine, bitmap_rgb32 &bitmap)
2055void namcos23_state::render_run(bitmap_rgb32 &bitmap)
20382056{
2039   namcos23_state *state = machine.driver_data<namcos23_state>();
2040   render_t &render = state->m_render;
2057   render_t &render = m_render;
20412058   const namcos23_render_entry *re = render.entries[!render.cur];
20422059
20432060   render.poly_count = 0;
r21058r21059
20462063      switch(re->type)
20472064      {
20482065      case MODEL:
2049         render_one_model(machine, re);
2066         render_one_model(re);
20502067         break;
20512068      case FLUSH:
2052         render_flush(machine, bitmap);
2069         render_flush(bitmap);
20532070         break;
20542071      }
20552072      re++;
20562073   }
2057   render_flush(machine, bitmap);
2074   render_flush(bitmap);
20582075
20592076   poly_wait(render.polymgr, "render_run");
20602077}
r21058r21059
21382155   update_mixer();
21392156   bitmap.fill(m_c404.bgcolor, cliprect);
21402157
2141   render_run(machine(), bitmap);
2158   render_run(bitmap);
21422159
21432160   m_bgtilemap->set_palette_offset(m_c404.palbase);
21442161   if (m_c404.layer & 4)
trunk/src/mame/drivers/kingdrby.c
r21058r21059
111111   DECLARE_PALETTE_INIT(kingdrby);
112112   DECLARE_PALETTE_INIT(kingdrbb);
113113   UINT32 screen_update_kingdrby(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
114   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
114115};
115116
116117
r21058r21059
183184   0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x22, 0x22
184185};
185186
186static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
187void kingdrby_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
187188{
188   kingdrby_state *state = machine.driver_data<kingdrby_state>();
189   UINT8 *spriteram = state->m_spriteram;
189   UINT8 *spriteram = m_spriteram;
190190   int count = 0;
191191
192192   /*sprites not fully understood.*/
r21058r21059
217217      {
218218         for(dy=0;dy<h;dy++)
219219            for(dx=0;dx<w;dx++)
220               drawgfx_transpen(bitmap,cliprect,machine.gfx[0],spr_offs++,colour,1,0,((x+16*w)-(dx+1)*16),(y+dy*16),0);
220               drawgfx_transpen(bitmap,cliprect,machine().gfx[0],spr_offs++,colour,1,0,((x+16*w)-(dx+1)*16),(y+dy*16),0);
221221      }
222222      else
223223      {
224224         for(dy=0;dy<h;dy++)
225225            for(dx=0;dx<w;dx++)
226               drawgfx_transpen(bitmap,cliprect,machine.gfx[0],spr_offs++,colour,0,0,(x+dx*16),(y+dy*16),0);
226               drawgfx_transpen(bitmap,cliprect,machine().gfx[0],spr_offs++,colour,0,0,(x+dx*16),(y+dy*16),0);
227227      }
228228   }
229229}
r21058r21059
243243
244244   /*TILEMAP_DRAW_CATEGORY + TILEMAP_DRAW_OPAQUE doesn't suit well?*/
245245   m_sc0_tilemap->draw(bitmap, cliprect, 0,0);
246   draw_sprites(machine(),bitmap,cliprect);
246   draw_sprites(bitmap,cliprect);
247247   m_sc1_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_CATEGORY(1),0);
248248   m_sc0w_tilemap->draw(bitmap, clip, 0,0);
249249
trunk/src/mame/drivers/multigam.c
r21058r21059
146146   DECLARE_MACHINE_START(supergm3);
147147   UINT32 screen_update_multigam(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
148148   TIMER_CALLBACK_MEMBER(mmc1_resync_callback);
149   void set_videorom_bank( int start, int count, int bank, int bank_size_in_kb);
150   void set_videoram_bank( int start, int count, int bank, int bank_size_in_kb);
151   void multigam_init_mmc3(UINT8 *prg_base, int prg_size, int chr_bank_base);
152   void multigam_init_mapper02(UINT8* prg_base, int prg_size);
153   void multigam_init_mmc1(UINT8 *prg_base, int prg_size, int chr_bank_base);
154   void supergm3_set_bank();
155   void multigm3_decrypt(UINT8* mem, int memsize, const UINT8* decode_nibble);
149156};
150157
151158
r21058r21059
203210
204211static const char * const banknames[] = { "bank2", "bank3", "bank4", "bank5", "bank6", "bank7", "bank8", "bank9" };
205212
206static void set_videorom_bank(running_machine& machine, int start, int count, int bank, int bank_size_in_kb)
213void multigam_state::set_videorom_bank( int start, int count, int bank, int bank_size_in_kb)
207214{
208215   int i;
209216   int offset = bank * (bank_size_in_kb * 0x400);
r21058r21059
211218   /* count determines the size of the area mapped in KB */
212219   for (i = 0; i < count; i++, offset += 0x400)
213220   {
214      machine.root_device().membank(banknames[i + start])->set_base(machine.root_device().memregion("gfx1")->base() + offset);
221      membank(banknames[i + start])->set_base(memregion("gfx1")->base() + offset);
215222   }
216223}
217224
218static void set_videoram_bank(running_machine& machine, int start, int count, int bank, int bank_size_in_kb)
225void multigam_state::set_videoram_bank( int start, int count, int bank, int bank_size_in_kb)
219226{
220   multigam_state *state = machine.driver_data<multigam_state>();
221227   int i;
222228   int offset = bank * (bank_size_in_kb * 0x400);
223229   /* bank_size_in_kb is used to determine how large the "bank" parameter is */
224230   /* count determines the size of the area mapped in KB */
225231   for (i = 0; i < count; i++, offset += 0x400)
226232   {
227      state->membank(banknames[i + start])->set_base(state->m_vram + offset);
233      membank(banknames[i + start])->set_base(m_vram + offset);
228234   }
229235}
230236
r21058r21059
466472               case 1: /* char banking */
467473                  data &= 0xfe;
468474                  page ^= (cmd << 1);
469                  set_videorom_bank(machine(), page, 2, m_multigam3_mmc3_chr_bank_base + data, 1);
475                  set_videorom_bank(page, 2, m_multigam3_mmc3_chr_bank_base + data, 1);
470476               break;
471477
472478               case 2: /* char banking */
r21058r21059
474480               case 4: /* char banking */
475481               case 5: /* char banking */
476482                  page ^= cmd + 2;
477                  set_videorom_bank(machine(), page, 1, m_multigam3_mmc3_chr_bank_base + data, 1);
483                  set_videorom_bank(page, 1, m_multigam3_mmc3_chr_bank_base + data, 1);
478484               break;
479485
480486               case 6: /* program banking */
r21058r21059
559565   }
560566}
561567
562static void multigam_init_mmc3(running_machine &machine, UINT8 *prg_base, int prg_size, int chr_bank_base)
568void multigam_state::multigam_init_mmc3(UINT8 *prg_base, int prg_size, int chr_bank_base)
563569{
564   multigam_state *state = machine.driver_data<multigam_state>();
565   UINT8* dst = state->memregion("maincpu")->base();
570   UINT8* dst = memregion("maincpu")->base();
566571
567572   // Tom & Jerry in Super Game III enables 6000 ram, but does not read/write it
568573   // however, it expects ROM from 6000 there (code jumps to $6xxx)
569   memcpy(state->m_multigmc_mmc3_6000_ram, dst + 0x6000, 0x2000);
574   memcpy(m_multigmc_mmc3_6000_ram, dst + 0x6000, 0x2000);
570575
571576   memcpy(&dst[0x8000], prg_base + (prg_size - 0x4000), 0x4000);
572577   memcpy(&dst[0xc000], prg_base + (prg_size - 0x4000), 0x4000);
573578
574   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(multigam_state::multigam3_mmc3_rom_switch_w),state));
579   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(multigam_state::multigam3_mmc3_rom_switch_w),this));
575580
576   state->m_multigam3_mmc3_banks[0] = 0x1e;
577   state->m_multigam3_mmc3_banks[1] = 0x1f;
578   state->m_multigam3_mmc3_scanline_counter = 0;
579   state->m_multigam3_mmc3_scanline_latch = 0;
580   state->m_multigam3_mmc3_4screen = 0;
581   state->m_multigam3_mmc3_last_bank = 0xff;
582   state->m_multigam3_mmc3_prg_base = prg_base;
583   state->m_multigam3_mmc3_chr_bank_base = chr_bank_base;
584   state->m_multigam3_mmc3_prg_size = prg_size;
581   m_multigam3_mmc3_banks[0] = 0x1e;
582   m_multigam3_mmc3_banks[1] = 0x1f;
583   m_multigam3_mmc3_scanline_counter = 0;
584   m_multigam3_mmc3_scanline_latch = 0;
585   m_multigam3_mmc3_4screen = 0;
586   m_multigam3_mmc3_last_bank = 0xff;
587   m_multigam3_mmc3_prg_base = prg_base;
588   m_multigam3_mmc3_chr_bank_base = chr_bank_base;
589   m_multigam3_mmc3_prg_size = prg_size;
585590};
586591
587592WRITE8_MEMBER(multigam_state::multigm3_mapper2_w)
588593{
589594   if (m_game_gfx_bank & 0x80)
590595   {
591      set_videorom_bank(machine(), 0, 8, (m_game_gfx_bank & 0x3c)  + (data & 0x3), 8);
596      set_videorom_bank(0, 8, (m_game_gfx_bank & 0x3c)  + (data & 0x3), 8);
592597   }
593598   else
594599   {
r21058r21059
598603
599604WRITE8_MEMBER(multigam_state::multigm3_switch_gfx_rom)
600605{
601   set_videorom_bank(machine(), 0, 8, data & 0x3f, 8);
606   set_videorom_bank(0, 8, data & 0x3f, 8);
602607   set_mirroring(data & 0x40 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
603608   m_game_gfx_bank = data;
604609};
r21058r21059
611616
612617   if (data == 0xa8)
613618   {
614      multigam_init_mmc3(machine(), src + 0xa0000, 0x40000, 0x180);
619      multigam_init_mmc3(src + 0xa0000, 0x40000, 0x180);
615620      return;
616621   }
617622   else
r21058r21059
674679   memcpy(mem + 0x8000, m_mapper02_prg_base + 0x4000*(data & bankmask), 0x4000);
675680}
676681
677static void multigam_init_mapper02(running_machine &machine, UINT8* prg_base, int prg_size)
682void multigam_state::multigam_init_mapper02(UINT8* prg_base, int prg_size)
678683{
679   multigam_state *state = machine.driver_data<multigam_state>();
680   ppu2c0x_device *ppu = machine.device<ppu2c0x_device>("ppu");
681   UINT8* mem = state->memregion("maincpu")->base();
684   ppu2c0x_device *ppu = machine().device<ppu2c0x_device>("ppu");
685   UINT8* mem = memregion("maincpu")->base();
682686   memcpy(mem + 0x8000, prg_base + prg_size - 0x8000, 0x8000);
683   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(multigam_state::multigam3_mapper02_rom_switch_w),state));
687   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(multigam_state::multigam3_mapper02_rom_switch_w),this));
684688
685   state->m_mapper02_prg_base = prg_base;
686   state->m_mapper02_prg_size = prg_size;
689   m_mapper02_prg_base = prg_base;
690   m_mapper02_prg_size = prg_size;
687691   ppu->set_scanline_callback(0);
688692}
689693
r21058r21059
779783
780784         case 1: /* video rom banking - bank 0 - 4k or 8k */
781785            if (m_mmc1_chr_bank_base == 0)
782               set_videoram_bank(machine(), 0, (m_vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
786               set_videoram_bank(0, (m_vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
783787            else
784               set_videorom_bank(machine(), 0, (m_vrom4k) ? 4 : 8, m_mmc1_chr_bank_base + (m_mmc1_shiftreg & 0x1f), 4);
788               set_videorom_bank(0, (m_vrom4k) ? 4 : 8, m_mmc1_chr_bank_base + (m_mmc1_shiftreg & 0x1f), 4);
785789         break;
786790
787791         case 2: /* video rom banking - bank 1 - 4k only */
788792            if (m_vrom4k)
789793            {
790794               if (m_mmc1_chr_bank_base == 0)
791                  set_videoram_bank(machine(), 0, (m_vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
795                  set_videoram_bank(0, (m_vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
792796               else
793                  set_videorom_bank(machine(), 4, 4, m_mmc1_chr_bank_base + (m_mmc1_shiftreg & 0x1f), 4);
797                  set_videorom_bank(4, 4, m_mmc1_chr_bank_base + (m_mmc1_shiftreg & 0x1f), 4);
794798            }
795799         break;
796800
r21058r21059
827831   }
828832}
829833
830static void multigam_init_mmc1(running_machine &machine, UINT8 *prg_base, int prg_size, int chr_bank_base)
834void multigam_state::multigam_init_mmc1(UINT8 *prg_base, int prg_size, int chr_bank_base)
831835{
832   multigam_state *state = machine.driver_data<multigam_state>();
833   UINT8* dst = state->memregion("maincpu")->base();
834   ppu2c0x_device *ppu = machine.device<ppu2c0x_device>("ppu");
836   UINT8* dst = memregion("maincpu")->base();
837   ppu2c0x_device *ppu = machine().device<ppu2c0x_device>("ppu");
835838
836839   memcpy(&dst[0x8000], prg_base + (prg_size - 0x8000), 0x8000);
837840
838   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(multigam_state::mmc1_rom_switch_w),state));
841   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8_delegate(FUNC(multigam_state::mmc1_rom_switch_w),this));
839842
840   state->m_mmc1_reg_write_enable = 1;
841   state->m_mmc1_rom_mask = (prg_size / 0x4000) - 1;
842   state->m_mmc1_prg_base = prg_base;
843   state->m_mmc1_prg_size = prg_size;
844   state->m_mmc1_chr_bank_base = chr_bank_base;
843   m_mmc1_reg_write_enable = 1;
844   m_mmc1_rom_mask = (prg_size / 0x4000) - 1;
845   m_mmc1_prg_base = prg_base;
846   m_mmc1_prg_size = prg_size;
847   m_mmc1_chr_bank_base = chr_bank_base;
845848
846849   ppu->set_scanline_callback(0);
847850};
r21058r21059
869872*/
870873
871874
872static void supergm3_set_bank(running_machine &machine)
875void multigam_state::supergm3_set_bank()
873876{
874   multigam_state *state = machine.driver_data<multigam_state>();
875   ppu2c0x_device *ppu = machine.device<ppu2c0x_device>("ppu");
876   UINT8* mem = state->memregion("maincpu")->base();
877   ppu2c0x_device *ppu = machine().device<ppu2c0x_device>("ppu");
878   UINT8* mem = memregion("maincpu")->base();
877879
878880   // video bank
879   if (state->m_supergm3_chr_bank == 0x10 ||
880      state->m_supergm3_chr_bank == 0x40 )
881   if (m_supergm3_chr_bank == 0x10 ||
882      m_supergm3_chr_bank == 0x40 )
881883   {
882884      // VRAM
883885      ppu->space(AS_PROGRAM).install_read_bank(0x0000, 0x1fff, "bank1");
884886      ppu->space(AS_PROGRAM).install_write_bank(0x0000, 0x1fff, "bank1");
885      state->membank("bank1")->set_base(state->m_vram);
887      membank("bank1")->set_base(m_vram);
886888
887      if (state->m_supergm3_chr_bank == 0x40)
888         state->set_mirroring(PPU_MIRROR_VERT);
889      if (m_supergm3_chr_bank == 0x40)
890         set_mirroring(PPU_MIRROR_VERT);
889891   }
890892   else
891893   {
r21058r21059
899901      ppu->space(AS_PROGRAM).install_read_bank(0x1c00, 0x1fff, "bank9");
900902      ppu->space(AS_PROGRAM).unmap_write(0x0000, 0x1fff);
901903
902      set_videorom_bank(machine, 0, 8, 0, 8);
904      set_videorom_bank(0, 8, 0, 8);
903905   }
904906
905907   // prg bank
906   if ((state->m_supergm3_prg_bank & 0x80) == 0)
908   if ((m_supergm3_prg_bank & 0x80) == 0)
907909   {
908910      // title screen
909911      memcpy(mem + 0x8000, mem + 0x18000, 0x8000);
910      state->membank("bank10")->set_base(mem + 0x6000);
912      membank("bank10")->set_base(mem + 0x6000);
911913      ppu->set_scanline_callback(0);
912914   }
913   else if ((state->m_supergm3_prg_bank & 0x40) == 0)
915   else if ((m_supergm3_prg_bank & 0x40) == 0)
914916   {
915917      // mapper 02
916      multigam_init_mapper02(machine,
917         machine.root_device().memregion("user1")->base() + (state->m_supergm3_prg_bank & 0x1f)*0x20000,
918      multigam_init_mapper02(memregion("user1")->base() + (m_supergm3_prg_bank & 0x1f)*0x20000,
918919         0x20000);
919920   }
920   else if (state->m_supergm3_chr_bank & 0x10)
921   else if (m_supergm3_chr_bank & 0x10)
921922   {
922923      // MMC3
923      multigam_init_mmc3(machine,
924         machine.root_device().memregion("user1")->base() + (state->m_supergm3_prg_bank & 0x1f)*0x20000,
925         (state->m_supergm3_prg_bank & 0x20) ? 0x20000 : 0x40000,
926         (state->m_supergm3_chr_bank & 0x0f)*0x80);
924      multigam_init_mmc3(memregion("user1")->base() + (m_supergm3_prg_bank & 0x1f)*0x20000,
925         (m_supergm3_prg_bank & 0x20) ? 0x20000 : 0x40000,
926         (m_supergm3_chr_bank & 0x0f)*0x80);
927927   }
928928   else
929929   {
930930      //MMC1
931      multigam_init_mmc1(machine,
932         machine.root_device().memregion("user1")->base() + (state->m_supergm3_prg_bank & 0x1f)*0x20000,
931      multigam_init_mmc1(memregion("user1")->base() + (m_supergm3_prg_bank & 0x1f)*0x20000,
933932         0x20000,
934         (state->m_supergm3_chr_bank & 0x0f)*0x80/4 );
933         (m_supergm3_chr_bank & 0x0f)*0x80/4 );
935934   }
936935}
937936
r21058r21059
943942WRITE8_MEMBER(multigam_state::supergm3_chr_bank_w)
944943{
945944   m_supergm3_chr_bank = data;
946   supergm3_set_bank(machine());
945   supergm3_set_bank();
947946}
948947
949948/******************************************************
r21058r21059
11761175   machine().device("ppu")->memory().space(AS_PROGRAM).install_read_bank(0x1800, 0x1bff, "bank8");
11771176   machine().device("ppu")->memory().space(AS_PROGRAM).install_read_bank(0x1c00, 0x1fff, "bank9");
11781177
1179   set_videorom_bank(machine(), 0, 8, 0, 8);
1178   set_videorom_bank(0, 8, 0, 8);
11801179};
11811180
11821181MACHINE_START_MEMBER(multigam_state,supergm3)
r21058r21059
13651364   multigam_switch_prg_rom(space, 0x0, 0x01);
13661365}
13671366
1368static void multigm3_decrypt(UINT8* mem, int memsize, const UINT8* decode_nibble)
1367void multigam_state::multigm3_decrypt(UINT8* mem, int memsize, const UINT8* decode_nibble)
13691368{
13701369   int i;
13711370   for (i = 0; i < memsize; i++)
trunk/src/mame/drivers/jalmah.c
r21058r21059
207207   UINT32 screen_update_jalmah(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
208208   UINT32 screen_update_urashima(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
209209   TIMER_DEVICE_CALLBACK_MEMBER(jalmah_mcu_sim);
210   void jalmah_priority_system();
211   void draw_sc0_layer(bitmap_ind16 &bitmap, const rectangle &cliprect);
212   void draw_sc1_layer(bitmap_ind16 &bitmap, const rectangle &cliprect);
213   void draw_sc2_layer(bitmap_ind16 &bitmap, const rectangle &cliprect);
214   void draw_sc3_layer(bitmap_ind16 &bitmap, const rectangle &cliprect);
215   void daireika_palette_dma(UINT16 val);
216   void daireika_mcu_run();
217   void mjzoomin_mcu_run();
218   void urashima_mcu_run();
219   void second_mcu_run();
210220};
211221
212222
r21058r21059
366376In the end the final results always are one bit assigned to each priority (i.e. most
367377priority = 8, then 4, 2 and finally 1).
368378***************************************************************************************/
369static void jalmah_priority_system(running_machine &machine)
379void jalmah_state::jalmah_priority_system()
370380{
371   jalmah_state *state = machine.driver_data<jalmah_state>();
372   UINT8 *pri_rom = state->memregion("user1")->base();
381   UINT8 *pri_rom = memregion("user1")->base();
373382   UINT8 i;
374383   UINT8 prinum[0x10];
375384
376   state->m_sc0_prin = 0;
377   state->m_sc1_prin = 0;
378   state->m_sc2_prin = 0;
379   state->m_sc3_prin = 0;
385   m_sc0_prin = 0;
386   m_sc1_prin = 0;
387   m_sc2_prin = 0;
388   m_sc3_prin = 0;
380389
381390   for(i=0;i<0x10;i++)
382391   {
383      prinum[i] = pri_rom[i+state->m_pri*0x10];
392      prinum[i] = pri_rom[i+m_pri*0x10];
384393
385      if(prinum[i] == 0) { state->m_sc0_prin++; }
386      if(prinum[i] == 1) { state->m_sc1_prin++; }
387      if(prinum[i] == 2) { state->m_sc2_prin++; }
388      if(prinum[i] == 3) { state->m_sc3_prin++; }
394      if(prinum[i] == 0) { m_sc0_prin++; }
395      if(prinum[i] == 1) { m_sc1_prin++; }
396      if(prinum[i] == 2) { m_sc2_prin++; }
397      if(prinum[i] == 3) { m_sc3_prin++; }
389398   }
390399
391   //popmessage("%02x %02x %02x %02x",state->m_sc0_prin,state->m_sc1_prin,state->m_sc2_prin,state->m_sc3_prin);
400   //popmessage("%02x %02x %02x %02x",m_sc0_prin,m_sc1_prin,m_sc2_prin,m_sc3_prin);
392401}
393402
394static void draw_sc0_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
403void jalmah_state::draw_sc0_layer(bitmap_ind16 &bitmap, const rectangle &cliprect)
395404{
396   jalmah_state *state = machine.driver_data<jalmah_state>();
397   switch(state->m_jm_vregs[0] & 3)
405   switch(m_jm_vregs[0] & 3)
398406   {
399      case 0: state->m_sc0_tilemap_0->draw(bitmap, cliprect, 0,0); break;
400      case 1: state->m_sc0_tilemap_1->draw(bitmap, cliprect, 0,0); break;
401      case 2: state->m_sc0_tilemap_2->draw(bitmap, cliprect, 0,0); break;
402      case 3: state->m_sc0_tilemap_3->draw(bitmap, cliprect, 0,0); break;
407      case 0: m_sc0_tilemap_0->draw(bitmap, cliprect, 0,0); break;
408      case 1: m_sc0_tilemap_1->draw(bitmap, cliprect, 0,0); break;
409      case 2: m_sc0_tilemap_2->draw(bitmap, cliprect, 0,0); break;
410      case 3: m_sc0_tilemap_3->draw(bitmap, cliprect, 0,0); break;
403411   }
404412}
405413
406static void draw_sc1_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
414void jalmah_state::draw_sc1_layer(bitmap_ind16 &bitmap, const rectangle &cliprect)
407415{
408   jalmah_state *state = machine.driver_data<jalmah_state>();
409   switch(state->m_jm_vregs[1] & 3)
416   switch(m_jm_vregs[1] & 3)
410417   {
411      case 0: state->m_sc1_tilemap_0->draw(bitmap, cliprect, 0,0); break;
412      case 1: state->m_sc1_tilemap_1->draw(bitmap, cliprect, 0,0); break;
413      case 2: state->m_sc1_tilemap_2->draw(bitmap, cliprect, 0,0); break;
414      case 3: state->m_sc1_tilemap_3->draw(bitmap, cliprect, 0,0); break;
418      case 0: m_sc1_tilemap_0->draw(bitmap, cliprect, 0,0); break;
419      case 1: m_sc1_tilemap_1->draw(bitmap, cliprect, 0,0); break;
420      case 2: m_sc1_tilemap_2->draw(bitmap, cliprect, 0,0); break;
421      case 3: m_sc1_tilemap_3->draw(bitmap, cliprect, 0,0); break;
415422   }
416423}
417424
418static void draw_sc2_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
425void jalmah_state::draw_sc2_layer(bitmap_ind16 &bitmap, const rectangle &cliprect)
419426{
420   jalmah_state *state = machine.driver_data<jalmah_state>();
421   switch(state->m_jm_vregs[2] & 3)
427   switch(m_jm_vregs[2] & 3)
422428   {
423      case 0: state->m_sc2_tilemap_0->draw(bitmap, cliprect, 0,0); break;
424      case 1: state->m_sc2_tilemap_1->draw(bitmap, cliprect, 0,0); break;
425      case 2: state->m_sc2_tilemap_2->draw(bitmap, cliprect, 0,0); break;
426      case 3: state->m_sc2_tilemap_3->draw(bitmap, cliprect, 0,0); break;
429      case 0: m_sc2_tilemap_0->draw(bitmap, cliprect, 0,0); break;
430      case 1: m_sc2_tilemap_1->draw(bitmap, cliprect, 0,0); break;
431      case 2: m_sc2_tilemap_2->draw(bitmap, cliprect, 0,0); break;
432      case 3: m_sc2_tilemap_3->draw(bitmap, cliprect, 0,0); break;
427433   }
428434}
429435
430static void draw_sc3_layer(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
436void jalmah_state::draw_sc3_layer(bitmap_ind16 &bitmap, const rectangle &cliprect)
431437{
432   jalmah_state *state = machine.driver_data<jalmah_state>();
433   switch(state->m_jm_vregs[3] & 3)
438   switch(m_jm_vregs[3] & 3)
434439   {
435440      case 0:
436      case 1: state->m_sc3_tilemap_0->draw(bitmap, cliprect, 0,0); break;
437      case 2: state->m_sc3_tilemap_2->draw(bitmap, cliprect, 0,0); break;
438      case 3: state->m_sc3_tilemap_3->draw(bitmap, cliprect, 0,0); break;
441      case 1: m_sc3_tilemap_0->draw(bitmap, cliprect, 0,0); break;
442      case 2: m_sc3_tilemap_2->draw(bitmap, cliprect, 0,0); break;
443      case 3: m_sc3_tilemap_3->draw(bitmap, cliprect, 0,0); break;
439444   }
440445}
441446
r21058r21059
443448{
444449   UINT16 *jm_scrollram = m_jm_scrollram;
445450   UINT8 cur_prin;
446   jalmah_priority_system(machine());
451   jalmah_priority_system();
447452
448453   m_sc0_tilemap_0->set_scrollx(0, jm_scrollram[0] & 0xfff);
449454   m_sc0_tilemap_1->set_scrollx(0, jm_scrollram[0] & 0x7ff);
r21058r21059
490495
491496   for(cur_prin=1;cur_prin<=0x8;cur_prin<<=1)
492497   {
493      if(cur_prin==m_sc0_prin) { draw_sc0_layer(machine(),bitmap,cliprect); }
494      if(cur_prin==m_sc1_prin) { draw_sc1_layer(machine(),bitmap,cliprect); }
495      if(cur_prin==m_sc2_prin) { draw_sc2_layer(machine(),bitmap,cliprect); }
496      if(cur_prin==m_sc3_prin) { draw_sc3_layer(machine(),bitmap,cliprect); }
498      if(cur_prin==m_sc0_prin) { draw_sc0_layer(bitmap,cliprect); }
499      if(cur_prin==m_sc1_prin) { draw_sc1_layer(bitmap,cliprect); }
500      if(cur_prin==m_sc2_prin) { draw_sc2_layer(bitmap,cliprect); }
501      if(cur_prin==m_sc3_prin) { draw_sc3_layer(bitmap,cliprect); }
497502   }
498503
499504   return 0;
r21058r21059
712717
713718
714719#define MCU_READ(tag, _bit_, _offset_, _retval_) \
715if((0xffff - machine.root_device().ioport(tag)->read()) & _bit_) { jm_shared_ram[_offset_] = _retval_; }
720if((0xffff - ioport(tag)->read()) & _bit_) { jm_shared_ram[_offset_] = _retval_; }
716721
717722/*Funky "DMA" / protection thing*/
718723/*---- -x-- "DMA" execute.*/
r21058r21059
728733}
729734
730735/*same as $f00c0 sub-routine,but with additional work-around,to remove from here...*/
731static void daireika_palette_dma(running_machine &machine, UINT16 val)
736void jalmah_state::daireika_palette_dma(UINT16 val)
732737{
733   //jalmah_state *state = machine.driver_data<jalmah_state>();
734   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
738   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
735739   UINT32 index_1, index_2, src_addr, tmp_addr;
736740   /*a0=301c0+jm_shared_ram[0x540/2] & 0xf00 */
737741   /*a1=88000*/
r21058r21059
750754}
751755
752756/*RAM-based protection handlings*/
753static void daireika_mcu_run(running_machine &machine)
757void jalmah_state::daireika_mcu_run()
754758{
755   jalmah_state *state = machine.driver_data<jalmah_state>();
756   UINT16 *jm_shared_ram = state->m_jm_shared_ram;
759   UINT16 *jm_shared_ram = m_jm_shared_ram;
757760
758   if(((jm_shared_ram[0x550/2] & 0xf00) == 0x700) && ((jm_shared_ram[0x540/2] & 0xf00) != state->m_dma_old))
761   if(((jm_shared_ram[0x550/2] & 0xf00) == 0x700) && ((jm_shared_ram[0x540/2] & 0xf00) != m_dma_old))
759762   {
760      state->m_dma_old = jm_shared_ram[0x540/2] & 0xf00;
761      daireika_palette_dma(machine,((jm_shared_ram[0x540/2] & 0x0f00) >> 8));
763      m_dma_old = jm_shared_ram[0x540/2] & 0xf00;
764      daireika_palette_dma(((jm_shared_ram[0x540/2] & 0x0f00) >> 8));
762765   }
763766
764   if(state->m_test_mode)  //service_mode
767   if(m_test_mode)  //service_mode
765768   {
766      jm_shared_ram[0x000/2] = machine.root_device().ioport("KEY0")->read();
767      jm_shared_ram[0x002/2] = machine.root_device().ioport("KEY1")->read();
768      jm_shared_ram[0x004/2] = machine.root_device().ioport("KEY2")->read();
769      jm_shared_ram[0x006/2] = machine.root_device().ioport("KEY3")->read();
770      jm_shared_ram[0x008/2] = machine.root_device().ioport("KEY4")->read();
771      jm_shared_ram[0x00a/2] = machine.root_device().ioport("KEY5")->read();
769      jm_shared_ram[0x000/2] = ioport("KEY0")->read();
770      jm_shared_ram[0x002/2] = ioport("KEY1")->read();
771      jm_shared_ram[0x004/2] = ioport("KEY2")->read();
772      jm_shared_ram[0x006/2] = ioport("KEY3")->read();
773      jm_shared_ram[0x008/2] = ioport("KEY4")->read();
774      jm_shared_ram[0x00a/2] = ioport("KEY5")->read();
772775   }
773776   else
774777   {
r21058r21059
795798      MCU_READ("KEY1", 0x0002, 0x000/2, 0x13);        /*CHI   (trusted)*/
796799      MCU_READ("KEY0", 0x0004, 0x000/2, 0x14);        /*START1*/
797800   }
798   state->m_prg_prot++;
799   if(state->m_prg_prot > 0x10) { state->m_prg_prot = 0; }
800   jm_shared_ram[0x00e/2] = state->m_prg_prot;
801   m_prg_prot++;
802   if(m_prg_prot > 0x10) { m_prg_prot = 0; }
803   jm_shared_ram[0x00e/2] = m_prg_prot;
801804}
802805
803static void mjzoomin_mcu_run(running_machine &machine)
806void jalmah_state::mjzoomin_mcu_run()
804807{
805   jalmah_state *state = machine.driver_data<jalmah_state>();
806   UINT16 *jm_shared_ram = state->m_jm_shared_ram;
808   UINT16 *jm_shared_ram = m_jm_shared_ram;
807809
808   if(state->m_test_mode)  //service_mode
810   if(m_test_mode)  //service_mode
809811   {
810      jm_shared_ram[0x000/2] = state->ioport("KEY0")->read();
811      jm_shared_ram[0x002/2] = state->ioport("KEY1")->read();
812      jm_shared_ram[0x004/2] = state->ioport("KEY2")->read();
813      jm_shared_ram[0x006/2] = state->ioport("KEY3")->read();
814      jm_shared_ram[0x008/2] = state->ioport("KEY4")->read();
815      jm_shared_ram[0x00a/2] = state->ioport("KEY5")->read();
812      jm_shared_ram[0x000/2] = ioport("KEY0")->read();
813      jm_shared_ram[0x002/2] = ioport("KEY1")->read();
814      jm_shared_ram[0x004/2] = ioport("KEY2")->read();
815      jm_shared_ram[0x006/2] = ioport("KEY3")->read();
816      jm_shared_ram[0x008/2] = ioport("KEY4")->read();
817      jm_shared_ram[0x00a/2] = ioport("KEY5")->read();
816818   }
817819   else
818820   {
r21058r21059
839841      MCU_READ("KEY1", 0x0002, 0x000/2, 0x13);        /*CHI   (trusted)*/
840842      MCU_READ("KEY0", 0x0004, 0x000/2, 0x14);        /*START1*/
841843   }
842   jm_shared_ram[0x00c/2] = machine.rand() & 0xffff;
843   state->m_prg_prot++;
844   if(state->m_prg_prot > 0x10) { state->m_prg_prot = 0; }
845   jm_shared_ram[0x00e/2] = state->m_prg_prot;
844   jm_shared_ram[0x00c/2] = machine().rand() & 0xffff;
845   m_prg_prot++;
846   if(m_prg_prot > 0x10) { m_prg_prot = 0; }
847   jm_shared_ram[0x00e/2] = m_prg_prot;
846848}
847849
848static void urashima_mcu_run(running_machine &machine)
850void jalmah_state::urashima_mcu_run()
849851{
850   jalmah_state *state = machine.driver_data<jalmah_state>();
851   UINT16 *jm_shared_ram = state->m_jm_shared_ram;
852   UINT16 *jm_shared_ram = m_jm_shared_ram;
852853
853   if(state->m_test_mode)  //service_mode
854   if(m_test_mode)  //service_mode
854855   {
855      jm_shared_ram[0x300/2] = state->ioport("KEY0")->read();
856      jm_shared_ram[0x302/2] = state->ioport("KEY1")->read();
857      jm_shared_ram[0x304/2] = state->ioport("KEY2")->read();
858      jm_shared_ram[0x306/2] = state->ioport("KEY3")->read();
859      jm_shared_ram[0x308/2] = state->ioport("KEY4")->read();
860      jm_shared_ram[0x30a/2] = state->ioport("KEY5")->read();
856      jm_shared_ram[0x300/2] = ioport("KEY0")->read();
857      jm_shared_ram[0x302/2] = ioport("KEY1")->read();
858      jm_shared_ram[0x304/2] = ioport("KEY2")->read();
859      jm_shared_ram[0x306/2] = ioport("KEY3")->read();
860      jm_shared_ram[0x308/2] = ioport("KEY4")->read();
861      jm_shared_ram[0x30a/2] = ioport("KEY5")->read();
861862   }
862863   else
863864   {
r21058r21059
884885      MCU_READ("KEY1", 0x0002, 0x300/2, 0x13);        /*CHI   (trusted)*/
885886      MCU_READ("KEY0", 0x0004, 0x300/2, 0x14);        /*START1*/
886887   }
887   jm_shared_ram[0x30c/2] = machine.rand() & 0xffff;
888   state->m_prg_prot++;
889   if(state->m_prg_prot > 0x10) { state->m_prg_prot = 0; }
890   jm_shared_ram[0x30e/2] = state->m_prg_prot;
888   jm_shared_ram[0x30c/2] = machine().rand() & 0xffff;
889   m_prg_prot++;
890   if(m_prg_prot > 0x10) { m_prg_prot = 0; }
891   jm_shared_ram[0x30e/2] = m_prg_prot;
891892}
892893
893static void second_mcu_run(running_machine &machine)
894void jalmah_state::second_mcu_run()
894895{
895   jalmah_state *state = machine.driver_data<jalmah_state>();
896   UINT16 *jm_shared_ram = state->m_jm_shared_ram;
897   if(state->m_test_mode)  //service_mode
896   UINT16 *jm_shared_ram = m_jm_shared_ram;
897   if(m_test_mode)  //service_mode
898898   {
899      jm_shared_ram[0x200/2] = state->ioport("KEY0")->read();
900      jm_shared_ram[0x202/2] = state->ioport("KEY1")->read();
901      jm_shared_ram[0x204/2] = state->ioport("KEY2")->read();
899      jm_shared_ram[0x200/2] = ioport("KEY0")->read();
900      jm_shared_ram[0x202/2] = ioport("KEY1")->read();
901      jm_shared_ram[0x204/2] = ioport("KEY2")->read();
902902   }
903903   else
904904   {
r21058r21059
927927
928928//      MCU_READ("KEY0", 0x0004, 0x7b8/2, 0x03);        /*START1(correct?)  */
929929   }
930   jm_shared_ram[0x20c/2] = machine.rand() & 0xffff; //kakumei2
930   jm_shared_ram[0x20c/2] = machine().rand() & 0xffff; //kakumei2
931931
932932}
933933
r21058r21059
943943          #define KAKUMEI2_MCU (0x22)
944944          #define SUCHIPI_MCU  (0x23)
945945      */
946         case MJZOOMIN_MCU: mjzoomin_mcu_run(machine()); break;
947         case DAIREIKA_MCU: daireika_mcu_run(machine()); break;
948         case URASHIMA_MCU: urashima_mcu_run(machine()); break;
946         case MJZOOMIN_MCU: mjzoomin_mcu_run(); break;
947         case DAIREIKA_MCU: daireika_mcu_run(); break;
948         case URASHIMA_MCU: urashima_mcu_run(); break;
949949         case KAKUMEI_MCU:
950950         case KAKUMEI2_MCU:
951         case SUCHIPI_MCU:  second_mcu_run(machine()); break;
951         case SUCHIPI_MCU:  second_mcu_run(); break;
952952   }
953953}
954954
trunk/src/mame/drivers/sigmab98.c
r21058r21059
179179   void screen_eof_sammymdl(screen_device &screen, bool state);
180180   INTERRUPT_GEN_MEMBER(gegege_vblank_interrupt);
181181   TIMER_DEVICE_CALLBACK_MEMBER(sammymd1_irq);
182   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri_mask);
182183};
183184
184185
r21058r21059
224225
225226***************************************************************************/
226227
227static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri_mask)
228void sigmab98_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri_mask)
228229{
229   sigmab98_state *state = machine.driver_data<sigmab98_state>();
230   UINT8 *end      =   state->m_spriteram - 0x10;
231   UINT8 *s        =   end + state->m_spriteram.bytes();
230   UINT8 *end      =   m_spriteram - 0x10;
231   UINT8 *s        =   end + m_spriteram.bytes();
232232
233233   for ( ; s != end; s -= 0x10 )
234234   {
r21058r21059
296296      {
297297         for (x = x0; x != x1; x += dx)
298298         {
299            drawgfxzoom_transpen(   bitmap, cliprect, machine.gfx[gfx],
299            drawgfxzoom_transpen(   bitmap, cliprect, machine().gfx[gfx],
300300                              code++, color,
301301                              flipx, flipy,
302302                              (sx + x * dim) / 0x10000, (sy + y * dim) / 0x10000,
r21058r21059
325325   bitmap.fill(get_black_pen(machine()), cliprect);
326326
327327   // Draw from priority 3 (bottom, converted to a bitmask) to priority 0 (top)
328   draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 8);
329   draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 4);
330   draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 2);
331   draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 1);
328   draw_sprites(bitmap, cliprect, layers_ctrl & 8);
329   draw_sprites(bitmap, cliprect, layers_ctrl & 4);
330   draw_sprites(bitmap, cliprect, layers_ctrl & 2);
331   draw_sprites(bitmap, cliprect, layers_ctrl & 1);
332332
333333   return 0;
334334}
trunk/src/mame/drivers/peplus.c
r21058r21059
268268   virtual void palette_init();
269269   UINT32 screen_update_peplus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
270270   TIMER_CALLBACK_MEMBER(assert_lp_cb);
271   void peplus_load_superdata(const char *bank_name);
272   void peplus_init();
271273};
272274
273275static const UINT8  id_022[8] = { 0x00, 0x01, 0x04, 0x09, 0x13, 0x16, 0x18, 0x00 };
r21058r21059
311313* Memory Copy *
312314***************/
313315
314static void peplus_load_superdata(running_machine &machine, const char *bank_name)
316void peplus_state::peplus_load_superdata(const char *bank_name)
315317{
316   peplus_state *state = machine.driver_data<peplus_state>();
317   UINT8 *super_data = state->memregion(bank_name)->base();
318   UINT8 *super_data = memregion(bank_name)->base();
318319
319320   /* Distribute Superboard Data */
320   memcpy(state->m_s3000_ram, &super_data[0x3000], 0x1000);
321   memcpy(state->m_s5000_ram, &super_data[0x5000], 0x1000);
322   memcpy(state->m_s7000_ram, &super_data[0x7000], 0x1000);
323   memcpy(state->m_sb000_ram, &super_data[0xb000], 0x1000);
324   memcpy(state->m_sd000_ram, &super_data[0xd000], 0x1000);
325   memcpy(state->m_sf000_ram, &super_data[0xf000], 0x1000);
321   memcpy(m_s3000_ram, &super_data[0x3000], 0x1000);
322   memcpy(m_s5000_ram, &super_data[0x5000], 0x1000);
323   memcpy(m_s7000_ram, &super_data[0x7000], 0x1000);
324   memcpy(m_sb000_ram, &super_data[0xb000], 0x1000);
325   memcpy(m_sd000_ram, &super_data[0xd000], 0x1000);
326   memcpy(m_sf000_ram, &super_data[0xf000], 0x1000);
326327}
327328
328329
r21058r21059
431432   if (offset == 0x1fff && m_wingboard && data < 5)
432433   {
433434      sprintf(bank_name, "user%d", data + 1);
434      peplus_load_superdata(machine(), bank_name);
435      peplus_load_superdata(bank_name);
435436   }
436437
437438   m_cmos_ram[offset] = data;
r21058r21059
13771378*****************/
13781379
13791380/* Normal board */
1380static void peplus_init(running_machine &machine)
1381void peplus_state::peplus_init()
13811382{
1382   peplus_state *state = machine.driver_data<peplus_state>();
13831383   /* default : no address to patch in program RAM to enable autohold feature */
1384   state->m_autohold_addr = 0;
1384   m_autohold_addr = 0;
13851385}
13861386
13871387
r21058r21059
13941394{
13951395   m_wingboard = FALSE;
13961396   m_jumper_e16_e17 = FALSE;
1397   peplus_init(machine());
1397   peplus_init();
13981398}
13991399
14001400/* Superboard */
r21058r21059
14021402{
14031403   m_wingboard = FALSE;
14041404   m_jumper_e16_e17 = FALSE;
1405   peplus_load_superdata(machine(), "user1");
1405   peplus_load_superdata("user1");
14061406
1407   peplus_init(machine());
1407   peplus_init();
14081408}
14091409
14101410/* Superboard with Attached Wingboard */
r21058r21059
14121412{
14131413   m_wingboard = TRUE;
14141414   m_jumper_e16_e17 = TRUE;
1415   peplus_load_superdata(machine(), "user1");
1415   peplus_load_superdata("user1");
14161416
1417   peplus_init(machine());
1417   peplus_init();
14181418}
14191419
14201420
trunk/src/mame/drivers/vegas.c
r21058r21059
505505   UINT32 screen_update_vegas(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
506506   TIMER_CALLBACK_MEMBER(nile_timer_callback);
507507   void remap_dynamic_addresses();
508   void update_nile_irqs();
509   void update_sio_irqs();
510   inline void _add_dynamic_address(offs_t start, offs_t end, read32_space_func read, write32_space_func write, const char *rdname, const char *wrname);
511   inline void _add_dynamic_device_address(device_t *device, offs_t start, offs_t end, read32_device_func read, write32_device_func write, const char *rdname, const char *wrname);
512   
513   void init_common(int ioasic, int serialnum);
508514};
509515
510516
r21058r21059
843849 *
844850 *************************************/
845851
846static void update_nile_irqs(running_machine &machine)
852void vegas_state::update_nile_irqs()
847853{
848   vegas_state *state = machine.driver_data<vegas_state>();
849   UINT32 intctll = state->m_nile_regs[NREG_INTCTRL+0];
850   UINT32 intctlh = state->m_nile_regs[NREG_INTCTRL+1];
854   UINT32 intctll = m_nile_regs[NREG_INTCTRL+0];
855   UINT32 intctlh = m_nile_regs[NREG_INTCTRL+1];
851856   UINT8 irq[6];
852857   int i;
853858
854859   /* check for UART transmit IRQ enable and synthsize one */
855   if (state->m_nile_regs[NREG_UARTIER] & 2)
856      state->m_nile_irq_state |= 0x0010;
860   if (m_nile_regs[NREG_UARTIER] & 2)
861      m_nile_irq_state |= 0x0010;
857862   else
858      state->m_nile_irq_state &= ~0x0010;
863      m_nile_irq_state &= ~0x0010;
859864
860865   irq[0] = irq[1] = irq[2] = irq[3] = irq[4] = irq[5] = 0;
861   state->m_nile_regs[NREG_INTSTAT0+0] = 0;
862   state->m_nile_regs[NREG_INTSTAT0+1] = 0;
863   state->m_nile_regs[NREG_INTSTAT1+0] = 0;
864   state->m_nile_regs[NREG_INTSTAT1+1] = 0;
866   m_nile_regs[NREG_INTSTAT0+0] = 0;
867   m_nile_regs[NREG_INTSTAT0+1] = 0;
868   m_nile_regs[NREG_INTSTAT1+0] = 0;
869   m_nile_regs[NREG_INTSTAT1+1] = 0;
865870
866871   /* handle the lower interrupts */
867872   for (i = 0; i < 8; i++)
868      if (state->m_nile_irq_state & (1 << i))
873      if (m_nile_irq_state & (1 << i))
869874         if ((intctll >> (4*i+3)) & 1)
870875         {
871876            int vector = (intctll >> (4*i)) & 7;
872877            if (vector < 6)
873878            {
874879               irq[vector] = 1;
875               state->m_nile_regs[NREG_INTSTAT0 + vector/2] |= 1 << (i + 16*(vector&1));
880               m_nile_regs[NREG_INTSTAT0 + vector/2] |= 1 << (i + 16*(vector&1));
876881            }
877882         }
878883
879884   /* handle the upper interrupts */
880885   for (i = 0; i < 8; i++)
881      if (state->m_nile_irq_state & (1 << (i+8)))
886      if (m_nile_irq_state & (1 << (i+8)))
882887         if ((intctlh >> (4*i+3)) & 1)
883888         {
884889            int vector = (intctlh >> (4*i)) & 7;
885890            if (vector < 6)
886891            {
887892               irq[vector] = 1;
888               state->m_nile_regs[NREG_INTSTAT0 + vector/2] |= 1 << (i + 8 + 16*(vector&1));
893               m_nile_regs[NREG_INTSTAT0 + vector/2] |= 1 << (i + 8 + 16*(vector&1));
889894            }
890895         }
891896
r21058r21059
896901      if (irq[i])
897902      {
898903         if (LOG_NILE_IRQS) logerror(" 1");
899         machine.device("maincpu")->execute().set_input_line(MIPS3_IRQ0 + i, ASSERT_LINE);
904         machine().device("maincpu")->execute().set_input_line(MIPS3_IRQ0 + i, ASSERT_LINE);
900905      }
901906      else
902907      {
903908         if (LOG_NILE_IRQS) logerror(" 0");
904         machine.device("maincpu")->execute().set_input_line(MIPS3_IRQ0 + i, CLEAR_LINE);
909         machine().device("maincpu")->execute().set_input_line(MIPS3_IRQ0 + i, CLEAR_LINE);
905910      }
906911   }
907912   if (LOG_NILE_IRQS) logerror("\n");
r21058r21059
929934   if (which == 3)
930935      m_nile_irq_state |= 1 << 5;
931936
932   update_nile_irqs(machine());
937   update_nile_irqs();
933938}
934939
935940
r21058r21059
10731078      case NREG_INTCTRL+1:    /* Interrupt control */
10741079         if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt control(%03X) = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
10751080         logit = 0;
1076         update_nile_irqs(space.machine());
1081         state->update_nile_irqs();
10771082         break;
10781083
10791084      case NREG_INTSTAT0+0:   /* Interrupt status 0 */
10801085      case NREG_INTSTAT0+1:   /* Interrupt status 0 */
10811086         if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt status 0(%03X) = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
10821087         logit = 0;
1083         update_nile_irqs(space.machine());
1088         state->update_nile_irqs();
10841089         break;
10851090
10861091      case NREG_INTSTAT1+0:   /* Interrupt status 1 */
10871092      case NREG_INTSTAT1+1:   /* Interrupt status 1 */
10881093         if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt status 1/enable(%03X) = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
10891094         logit = 0;
1090         update_nile_irqs(space.machine());
1095         state->update_nile_irqs();
10911096         break;
10921097
10931098      case NREG_INTCLR+0:     /* Interrupt clear */
r21058r21059
10951100         if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt clear(%03X) = %08X & %08X\n", space.device().safe_pc(), offset*4, data, mem_mask);
10961101         logit = 0;
10971102         state->m_nile_irq_state &= ~(state->m_nile_regs[offset] & ~0xf00);
1098         update_nile_irqs(space.machine());
1103         state->update_nile_irqs();
10991104         break;
11001105
11011106      case NREG_INTPPES+0:    /* PCI Interrupt control */
r21058r21059
11701175         logit = 0;
11711176         break;
11721177      case NREG_UARTIER:      /* serial interrupt enable */
1173         update_nile_irqs(space.machine());
1178         state->update_nile_irqs();
11741179         break;
11751180
11761181      case NREG_VID:
r21058r21059
12271232      m_nile_irq_state |= 0x800;
12281233   else
12291234      m_nile_irq_state &= ~0x800;
1230   update_nile_irqs(machine());
1235   update_nile_irqs();
12311236}
12321237
12331238
r21058r21059
12381243 *
12391244 *************************************/
12401245
1241static void update_sio_irqs(running_machine &machine)
1246void vegas_state::update_sio_irqs()
12421247{
1243   vegas_state *state = machine.driver_data<vegas_state>();
1244   if (state->m_sio_irq_state & state->m_sio_irq_enable)
1245      state->m_nile_irq_state |= 0x400;
1248   if (m_sio_irq_state & m_sio_irq_enable)
1249      m_nile_irq_state |= 0x400;
12461250   else
1247      state->m_nile_irq_state &= ~0x400;
1248   update_nile_irqs(machine);
1251      m_nile_irq_state &= ~0x400;
1252   update_nile_irqs();
12491253}
12501254
12511255
r21058r21059
12551259   if (!drvstate->m_vblank_state && state)
12561260   {
12571261      drvstate->m_sio_irq_state |= 0x20;
1258      update_sio_irqs(device->machine());
1262      drvstate->update_sio_irqs();
12591263   }
12601264   drvstate->m_vblank_state = state;
12611265
r21058r21059
12741278      drvstate->m_sio_irq_state |= 0x04;
12751279   else
12761280      drvstate->m_sio_irq_state &= ~0x04;
1277   update_sio_irqs(machine);
1281   drvstate->update_sio_irqs();
12781282}
12791283
12801284
r21058r21059
12851289      drvstate->m_sio_irq_state |= 0x10;
12861290   else
12871291      drvstate->m_sio_irq_state &= ~0x10;
1288   update_sio_irqs(device->machine());
1292   drvstate->update_sio_irqs();
12891293}
12901294
12911295
r21058r21059
13141318      if (!(data & 0x08))
13151319      {
13161320         state->m_sio_irq_state &= ~0x20;
1317         update_sio_irqs(space.machine());
1321         state->update_sio_irqs();
13181322      }
13191323   }
13201324}
r21058r21059
13331337   if (ACCESSING_BITS_0_7)
13341338   {
13351339      state->m_sio_irq_enable = data;
1336      update_sio_irqs(space.machine());
1340      state->update_sio_irqs();
13371341   }
13381342}
13391343
r21058r21059
15071511 *
15081512 *************************************/
15091513
1510#define add_dynamic_address(st,s,e,r,w)         _add_dynamic_address(st,s,e,r,w,#r,#w)
1511#define add_dynamic_device_address(st,d,s,e,r,w)    _add_dynamic_device_address(st,d,s,e,r,w,#r,#w)
1514#define add_dynamic_address(s,e,r,w)         _add_dynamic_address(s,e,r,w,#r,#w)
1515#define add_dynamic_device_address(d,s,e,r,w)    _add_dynamic_device_address(d,s,e,r,w,#r,#w)
15121516
1513INLINE void _add_dynamic_address(vegas_state *state, offs_t start, offs_t end, read32_space_func read, write32_space_func write, const char *rdname, const char *wrname)
1517inline void vegas_state::_add_dynamic_address(offs_t start, offs_t end, read32_space_func read, write32_space_func write, const char *rdname, const char *wrname)
15141518{
1515   dynamic_address *dynamic = state->m_dynamic;
1516   dynamic[state->m_dynamic_count].start = start;
1517   dynamic[state->m_dynamic_count].end = end;
1518   dynamic[state->m_dynamic_count].mread = read;
1519   dynamic[state->m_dynamic_count].mwrite = write;
1520   dynamic[state->m_dynamic_count].dread = NULL;
1521   dynamic[state->m_dynamic_count].dwrite = NULL;
1522   dynamic[state->m_dynamic_count].device = NULL;
1523   dynamic[state->m_dynamic_count].rdname = rdname;
1524   dynamic[state->m_dynamic_count].wrname = wrname;
1525   state->m_dynamic_count++;
1519   dynamic_address *dynamic = m_dynamic;
1520   dynamic[m_dynamic_count].start = start;
1521   dynamic[m_dynamic_count].end = end;
1522   dynamic[m_dynamic_count].mread = read;
1523   dynamic[m_dynamic_count].mwrite = write;
1524   dynamic[m_dynamic_count].dread = NULL;
1525   dynamic[m_dynamic_count].dwrite = NULL;
1526   dynamic[m_dynamic_count].device = NULL;
1527   dynamic[m_dynamic_count].rdname = rdname;
1528   dynamic[m_dynamic_count].wrname = wrname;
1529   m_dynamic_count++;
15261530}
15271531
1528INLINE void _add_dynamic_device_address(vegas_state *state, device_t *device, offs_t start, offs_t end, read32_device_func read, write32_device_func write, const char *rdname, const char *wrname)
1532inline void vegas_state::_add_dynamic_device_address(device_t *device, offs_t start, offs_t end, read32_device_func read, write32_device_func write, const char *rdname, const char *wrname)
15291533{
1530   dynamic_address *dynamic = state->m_dynamic;
1531   dynamic[state->m_dynamic_count].start = start;
1532   dynamic[state->m_dynamic_count].end = end;
1533   dynamic[state->m_dynamic_count].mread = NULL;
1534   dynamic[state->m_dynamic_count].mwrite = NULL;
1535   dynamic[state->m_dynamic_count].dread = read;
1536   dynamic[state->m_dynamic_count].dwrite = write;
1537   dynamic[state->m_dynamic_count].device = device;
1538   dynamic[state->m_dynamic_count].rdname = rdname;
1539   dynamic[state->m_dynamic_count].wrname = wrname;
1540   state->m_dynamic_count++;
1534   dynamic_address *dynamic = m_dynamic;
1535   dynamic[m_dynamic_count].start = start;
1536   dynamic[m_dynamic_count].end = end;
1537   dynamic[m_dynamic_count].mread = NULL;
1538   dynamic[m_dynamic_count].mwrite = NULL;
1539   dynamic[m_dynamic_count].dread = read;
1540   dynamic[m_dynamic_count].dwrite = write;
1541   dynamic[m_dynamic_count].device = device;
1542   dynamic[m_dynamic_count].rdname = rdname;
1543   dynamic[m_dynamic_count].wrname = wrname;
1544   m_dynamic_count++;
15411545}
15421546
15431547
r21058r21059
15611565   base = m_nile_regs[NREG_DCS2] & 0x1fffff00;
15621566   if (base >= m_rambase.bytes())
15631567   {
1564      add_dynamic_address(this, base + 0x0000, base + 0x0003, sio_irq_clear_r, sio_irq_clear_w);
1565      add_dynamic_address(this, base + 0x1000, base + 0x1003, sio_irq_enable_r, sio_irq_enable_w);
1566      add_dynamic_address(this, base + 0x2000, base + 0x2003, sio_irq_cause_r, NULL);
1567      add_dynamic_address(this, base + 0x3000, base + 0x3003, sio_irq_status_r, NULL);
1568      add_dynamic_address(this, base + 0x4000, base + 0x4003, sio_led_r, sio_led_w);
1569      add_dynamic_address(this, base + 0x5000, base + 0x5007, NOP_HANDLER, NULL);
1570      add_dynamic_address(this, base + 0x6000, base + 0x6003, NULL, cmos_unlock_w);
1571      add_dynamic_address(this, base + 0x7000, base + 0x7003, NULL, vegas_watchdog_w);
1568      add_dynamic_address(base + 0x0000, base + 0x0003, sio_irq_clear_r, sio_irq_clear_w);
1569      add_dynamic_address(base + 0x1000, base + 0x1003, sio_irq_enable_r, sio_irq_enable_w);
1570      add_dynamic_address(base + 0x2000, base + 0x2003, sio_irq_cause_r, NULL);
1571      add_dynamic_address(base + 0x3000, base + 0x3003, sio_irq_status_r, NULL);
1572      add_dynamic_address(base + 0x4000, base + 0x4003, sio_led_r, sio_led_w);
1573      add_dynamic_address(base + 0x5000, base + 0x5007, NOP_HANDLER, NULL);
1574      add_dynamic_address(base + 0x6000, base + 0x6003, NULL, cmos_unlock_w);
1575      add_dynamic_address(base + 0x7000, base + 0x7003, NULL, vegas_watchdog_w);
15721576   }
15731577
15741578   /* DCS3 */
15751579   base = m_nile_regs[NREG_DCS3] & 0x1fffff00;
15761580   if (base >= m_rambase.bytes())
1577      add_dynamic_address(this, base + 0x0000, base + 0x0003, analog_port_r, analog_port_w);
1581      add_dynamic_address(base + 0x0000, base + 0x0003, analog_port_r, analog_port_w);
15781582
15791583   /* DCS4 */
15801584   base = m_nile_regs[NREG_DCS4] & 0x1fffff00;
15811585   if (base >= m_rambase.bytes())
1582      add_dynamic_address(this, base + 0x0000, base + 0x7fff, timekeeper_r, timekeeper_w);
1586      add_dynamic_address(base + 0x0000, base + 0x7fff, timekeeper_r, timekeeper_w);
15831587
15841588   /* DCS5 */
15851589   base = m_nile_regs[NREG_DCS5] & 0x1fffff00;
15861590   if (base >= m_rambase.bytes())
1587      add_dynamic_address(this, base + 0x0000, base + 0x0003, sio_r, sio_w);
1591      add_dynamic_address(base + 0x0000, base + 0x0003, sio_r, sio_w);
15881592
15891593   /* DCS6 */
15901594   base = m_nile_regs[NREG_DCS6] & 0x1fffff00;
15911595   if (base >= m_rambase.bytes())
15921596   {
1593      add_dynamic_address(this, base + 0x0000, base + 0x003f, midway_ioasic_packed_r, midway_ioasic_packed_w);
1594      add_dynamic_address(this, base + 0x1000, base + 0x1003, NULL, asic_fifo_w);
1597      add_dynamic_address(base + 0x0000, base + 0x003f, midway_ioasic_packed_r, midway_ioasic_packed_w);
1598      add_dynamic_address(base + 0x1000, base + 0x1003, NULL, asic_fifo_w);
15951599      if (m_dcs_idma_cs != 0)
1596         add_dynamic_address(this, base + 0x3000, base + 0x3003, NULL, dcs3_fifo_full_w);
1600         add_dynamic_address(base + 0x3000, base + 0x3003, NULL, dcs3_fifo_full_w);
15971601      if (m_dcs_idma_cs == 6)
15981602      {
1599         add_dynamic_address(this, base + 0x5000, base + 0x5003, NULL, dsio_idma_addr_w);
1600         add_dynamic_address(this, base + 0x7000, base + 0x7003, dsio_idma_data_r, dsio_idma_data_w);
1603         add_dynamic_address(base + 0x5000, base + 0x5003, NULL, dsio_idma_addr_w);
1604         add_dynamic_address(base + 0x7000, base + 0x7003, dsio_idma_data_r, dsio_idma_data_w);
16011605      }
16021606   }
16031607
r21058r21059
16051609   base = m_nile_regs[NREG_DCS7] & 0x1fffff00;
16061610   if (base >= m_rambase.bytes())
16071611   {
1608      add_dynamic_device_address(this, ethernet, base + 0x1000, base + 0x100f, ethernet_r, ethernet_w);
1612      add_dynamic_device_address(ethernet, base + 0x1000, base + 0x100f, ethernet_r, ethernet_w);
16091613      if (m_dcs_idma_cs == 7)
16101614      {
1611         add_dynamic_address(this, base + 0x5000, base + 0x5003, NULL, dsio_idma_addr_w);
1612         add_dynamic_address(this, base + 0x7000, base + 0x7003, dsio_idma_data_r, dsio_idma_data_w);
1615         add_dynamic_address(base + 0x5000, base + 0x5003, NULL, dsio_idma_addr_w);
1616         add_dynamic_address(base + 0x7000, base + 0x7003, dsio_idma_data_r, dsio_idma_data_w);
16131617      }
16141618   }
16151619
r21058r21059
16191623      base = m_nile_regs[NREG_PCIW1] & 0x1fffff00;
16201624      if (base >= m_rambase.bytes())
16211625      {
1622         add_dynamic_address(this, base + (1 << (21 + 4)) + 0x0000, base + (1 << (21 + 4)) + 0x00ff, pci_3dfx_r, pci_3dfx_w);
1623         add_dynamic_address(this, base + (1 << (21 + 5)) + 0x0000, base + (1 << (21 + 5)) + 0x00ff, pci_ide_r, pci_ide_w);
1626         add_dynamic_address(base + (1 << (21 + 4)) + 0x0000, base + (1 << (21 + 4)) + 0x00ff, pci_3dfx_r, pci_3dfx_w);
1627         add_dynamic_address(base + (1 << (21 + 5)) + 0x0000, base + (1 << (21 + 5)) + 0x00ff, pci_ide_r, pci_ide_w);
16241628      }
16251629   }
16261630
r21058r21059
16301634      /* IDE controller */
16311635      base = m_pci_ide_regs[0x04] & 0xfffffff0;
16321636      if (base >= m_rambase.bytes() && base < 0x20000000)
1633         add_dynamic_device_address(this, ide, base + 0x0000, base + 0x000f, ide_main_r, ide_main_w);
1637         add_dynamic_device_address(ide, base + 0x0000, base + 0x000f, ide_main_r, ide_main_w);
16341638
16351639      base = m_pci_ide_regs[0x05] & 0xfffffffc;
16361640      if (base >= m_rambase.bytes() && base < 0x20000000)
1637         add_dynamic_device_address(this, ide, base + 0x0000, base + 0x0003, ide_alt_r, ide_alt_w);
1641         add_dynamic_device_address(ide, base + 0x0000, base + 0x0003, ide_alt_r, ide_alt_w);
16381642
16391643      base = m_pci_ide_regs[0x08] & 0xfffffff0;
16401644      if (base >= m_rambase.bytes() && base < 0x20000000)
1641         add_dynamic_device_address(this, ide, base + 0x0000, base + 0x0007, ide_bus_master32_r, ide_bus_master32_w);
1645         add_dynamic_device_address(ide, base + 0x0000, base + 0x0007, ide_bus_master32_r, ide_bus_master32_w);
16421646
16431647      /* 3dfx card */
16441648      base = m_pci_3dfx_regs[0x04] & 0xfffffff0;
16451649      if (base >= m_rambase.bytes() && base < 0x20000000)
16461650      {
16471651         if (voodoo_type == TYPE_VOODOO_2)
1648            add_dynamic_device_address(this, m_voodoo, base + 0x000000, base + 0xffffff, voodoo_r, voodoo_w);
1652            add_dynamic_device_address(m_voodoo, base + 0x000000, base + 0xffffff, voodoo_r, voodoo_w);
16491653         else
1650            add_dynamic_device_address(this, m_voodoo, base + 0x000000, base + 0x1ffffff, banshee_r, banshee_w);
1654            add_dynamic_device_address(m_voodoo, base + 0x000000, base + 0x1ffffff, banshee_r, banshee_w);
16511655      }
16521656
16531657      if (voodoo_type >= TYPE_VOODOO_BANSHEE)
16541658      {
16551659         base = m_pci_3dfx_regs[0x05] & 0xfffffff0;
16561660         if (base >= m_rambase.bytes() && base < 0x20000000)
1657            add_dynamic_device_address(this, m_voodoo, base + 0x0000000, base + 0x1ffffff, banshee_fb_r, banshee_fb_w);
1661            add_dynamic_device_address(m_voodoo, base + 0x0000000, base + 0x1ffffff, banshee_fb_r, banshee_fb_w);
16581662
16591663         base = m_pci_3dfx_regs[0x06] & 0xfffffff0;
16601664         if (base >= m_rambase.bytes() && base < 0x20000000)
1661            add_dynamic_device_address(this, m_voodoo, base + 0x0000000, base + 0x00000ff, banshee_io_r, banshee_io_w);
1665            add_dynamic_device_address(m_voodoo, base + 0x0000000, base + 0x00000ff, banshee_io_r, banshee_io_w);
16621666
16631667         base = m_pci_3dfx_regs[0x0c] & 0xffff0000;
16641668         if (base >= m_rambase.bytes() && base < 0x20000000)
1665            add_dynamic_device_address(this, m_voodoo, base + 0x0000000, base + 0x000ffff, banshee_rom_r, NULL);
1669            add_dynamic_device_address(m_voodoo, base + 0x0000000, base + 0x000ffff, banshee_rom_r, NULL);
16661670      }
16671671   }
16681672
r21058r21059
24732477 *
24742478 *************************************/
24752479
2476static void init_common(running_machine &machine, int ioasic, int serialnum)
2480void vegas_state::init_common(int ioasic, int serialnum)
24772481{
24782482   /* initialize the subsystems */
2479   midway_ioasic_init(machine, ioasic, serialnum, 80, ioasic_irq);
2483   midway_ioasic_init(machine(), ioasic, serialnum, 80, ioasic_irq);
24802484   midway_ioasic_set_auto_ack(1);
24812485}
24822486
r21058r21059
24842488DRIVER_INIT_MEMBER(vegas_state,gauntleg)
24852489{
24862490   dcs2_init(machine(), 4, 0x0b5d);
2487   init_common(machine(), MIDWAY_IOASIC_CALSPEED, 340/* 340=39", 322=27", others? */);
2491   init_common(MIDWAY_IOASIC_CALSPEED, 340/* 340=39", 322=27", others? */);
24882492
24892493   /* speedups */
24902494   mips3drc_add_hotspot(machine().device("maincpu"), 0x80015430, 0x8CC38060, 250);     /* confirmed */
r21058r21059
24972501DRIVER_INIT_MEMBER(vegas_state,gauntdl)
24982502{
24992503   dcs2_init(machine(), 4, 0x0b5d);
2500   init_common(machine(), MIDWAY_IOASIC_GAUNTDL, 346/* 347, others? */);
2504   init_common(MIDWAY_IOASIC_GAUNTDL, 346/* 347, others? */);
25012505
25022506   /* speedups */
25032507   mips3drc_add_hotspot(machine().device("maincpu"), 0x800158B8, 0x8CC3CC40, 250);     /* confirmed */
r21058r21059
25102514DRIVER_INIT_MEMBER(vegas_state,warfa)
25112515{
25122516   dcs2_init(machine(), 4, 0x0b5d);
2513   init_common(machine(), MIDWAY_IOASIC_MACE, 337/* others? */);
2517   init_common(MIDWAY_IOASIC_MACE, 337/* others? */);
25142518
25152519   /* speedups */
25162520   mips3drc_add_hotspot(machine().device("maincpu"), 0x8009436C, 0x0C031663, 250);     /* confirmed */
r21058r21059
25202524DRIVER_INIT_MEMBER(vegas_state,tenthdeg)
25212525{
25222526   dcs2_init(machine(), 4, 0x0afb);
2523   init_common(machine(), MIDWAY_IOASIC_GAUNTDL, 330/* others? */);
2527   init_common(MIDWAY_IOASIC_GAUNTDL, 330/* others? */);
25242528
25252529   /* speedups */
25262530   mips3drc_add_hotspot(machine().device("maincpu"), 0x80051CD8, 0x0C023C15, 250);     /* confirmed */
r21058r21059
25332537DRIVER_INIT_MEMBER(vegas_state,roadburn)
25342538{
25352539   dcs2_init(machine(), 4, 0); /* no place to hook :-( */
2536   init_common(machine(), MIDWAY_IOASIC_STANDARD, 325/* others? */);
2540   init_common(MIDWAY_IOASIC_STANDARD, 325/* others? */);
25372541}
25382542
25392543
25402544DRIVER_INIT_MEMBER(vegas_state,nbashowt)
25412545{
25422546   dcs2_init(machine(), 4, 0);
2543   init_common(machine(), MIDWAY_IOASIC_MACE, 528/* or 478 or 487 */);
2547   init_common(MIDWAY_IOASIC_MACE, 528/* or 478 or 487 */);
25442548}
25452549
25462550
25472551DRIVER_INIT_MEMBER(vegas_state,nbanfl)
25482552{
25492553   dcs2_init(machine(), 4, 0);
2550   init_common(machine(), MIDWAY_IOASIC_BLITZ99, 498/* or 478 or 487 */);
2554   init_common(MIDWAY_IOASIC_BLITZ99, 498/* or 478 or 487 */);
25512555   /* NOT: MACE */
25522556}
25532557
r21058r21059
25552559DRIVER_INIT_MEMBER(vegas_state,sf2049)
25562560{
25572561   dcs2_init(machine(), 8, 0);
2558   init_common(machine(), MIDWAY_IOASIC_STANDARD, 336/* others? */);
2562   init_common(MIDWAY_IOASIC_STANDARD, 336/* others? */);
25592563}
25602564
25612565
25622566DRIVER_INIT_MEMBER(vegas_state,sf2049se)
25632567{
25642568   dcs2_init(machine(), 8, 0);
2565   init_common(machine(), MIDWAY_IOASIC_SFRUSHRK, 336/* others? */);
2569   init_common(MIDWAY_IOASIC_SFRUSHRK, 336/* others? */);
25662570}
25672571
25682572
25692573DRIVER_INIT_MEMBER(vegas_state,sf2049te)
25702574{
25712575   dcs2_init(machine(), 8, 0);
2572   init_common(machine(), MIDWAY_IOASIC_SFRUSHRK, 348/* others? */);
2576   init_common(MIDWAY_IOASIC_SFRUSHRK, 348/* others? */);
25732577}
25742578
25752579
25762580DRIVER_INIT_MEMBER(vegas_state,cartfury)
25772581{
25782582   dcs2_init(machine(), 4, 0);
2579   init_common(machine(), MIDWAY_IOASIC_CARNEVIL, 495/* others? */);
2583   init_common(MIDWAY_IOASIC_CARNEVIL, 495/* others? */);
25802584}
25812585
25822586
trunk/src/mame/drivers/namcos11.c
r21058r21059
344344   TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq0_cb);
345345   TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq2_cb);
346346   TIMER_DEVICE_CALLBACK_MEMBER(mcu_adc_cb);
347   inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ... );
348   inline void bankswitch_rom8( address_space &space, const char *bank, int n_data );
349   inline void bankswitch_rom64( address_space &space, const char *bank, int n_data );
350   void namcos11_init_common(int n_daughterboard);
347351};
348352
349INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... )
353inline void ATTR_PRINTF(3,4) namcos11_state::verboselog( int n_level, const char *s_fmt, ... )
350354{
351355   if( VERBOSE_LEVEL >= n_level )
352356   {
r21058r21059
355359      va_start( v, s_fmt );
356360      vsprintf( buf, s_fmt, v );
357361      va_end( v );
358      logerror( "%s: %s", machine.describe_context(), buf );
362      logerror( "%s: %s", machine().describe_context(), buf );
359363   }
360364}
361365
362366WRITE32_MEMBER(namcos11_state::keycus_w)
363367{
364   verboselog( machine(), 1, "keycus_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
368   verboselog(1, "keycus_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
365369   COMBINE_DATA( &m_keycus[ offset ] );
366370}
367371
r21058r21059
383387         ( ( namcos11_keycus[ 1 ] >> 8 ) & 0xf );
384388      break;
385389   }
386   verboselog( machine(), 1, "keycus_c406_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
390   verboselog(1, "keycus_c406_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
387391   return data;
388392}
389393
r21058r21059
400404      data = ( data & 0x0000ffff ) | 0x000f0000;
401405      break;
402406   }
403   verboselog( machine(), 1, "keycus_c409_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
407   verboselog(1, "keycus_c409_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
404408   return data;
405409}
406410
r21058r21059
435439         ( ( ( n_value / 10000 ) % 10 ) << 16 );
436440      break;
437441   }
438   verboselog( machine(), 1, "keycus_c410_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
442   verboselog(1, "keycus_c410_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
439443   return data;
440444}
441445
r21058r21059
469473      break;
470474   }
471475
472   verboselog( machine(), 1, "keycus_c411_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
476   verboselog(1, "keycus_c411_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
473477   return data;
474478}
475479
r21058r21059
504508         ( ( ( n_value / 1 ) % 10 ) << 16 );
505509      break;
506510   }
507   verboselog( machine(), 1, "keycus_c430_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
511   verboselog(1, "keycus_c430_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
508512   return data;
509513}
510514
r21058r21059
537541      data = ( data & 0xffff0000 ) | ( ( n_value / 10000 ) % 10 );
538542      break;
539543   }
540   verboselog( machine(), 1, "keycus_c431_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
544   verboselog(1, "keycus_c431_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
541545   return data;
542546}
543547
r21058r21059
571575      break;
572576   }
573577
574   verboselog( machine(), 1, "keycus_c432_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
578   verboselog(1, "keycus_c432_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
575579   return data;
576580}
577581
r21058r21059
592596      }
593597      break;
594598   }
595   verboselog( machine(), 1, "keycus_c442_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
599   verboselog(1, "keycus_c442_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
596600   return data;
597601}
598602
r21058r21059
625629      }
626630      break;
627631   }
628   verboselog( machine(), 1, "keycus_c443_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
632   verboselog(1, "keycus_c443_r( %08x, %08x, %08x )\n", offset, data, mem_mask );
629633   return data;
630634}
631635
632INLINE void bankswitch_rom8( address_space &space, const char *bank, int n_data )
636inline void namcos11_state::bankswitch_rom8( address_space &space, const char *bank, int n_data )
633637{
634   space.machine().root_device().membank( bank )->set_entry( ( ( n_data & 0xc0 ) >> 4 ) + ( n_data & 0x03 ) );
638   membank( bank )->set_entry( ( ( n_data & 0xc0 ) >> 4 ) + ( n_data & 0x03 ) );
635639}
636640
637641static const char * const bankname[] = { "bank1", "bank2", "bank3", "bank4", "bank5", "bank6", "bank7", "bank8" };
638642
639643WRITE32_MEMBER(namcos11_state::bankswitch_rom32_w)
640644{
641   verboselog( machine(), 2, "bankswitch_rom32_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
645   verboselog(2, "bankswitch_rom32_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
642646
643647   if( ACCESSING_BITS_0_15 )
644648   {
r21058r21059
652656
653657WRITE32_MEMBER(namcos11_state::bankswitch_rom64_upper_w)
654658{
655   verboselog( machine(), 2, "bankswitch_rom64_upper_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
659   verboselog(2, "bankswitch_rom64_upper_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
656660
657661   if( ACCESSING_BITS_0_15 )
658662   {
r21058r21059
664668   }
665669}
666670
667INLINE void bankswitch_rom64( address_space &space, const char *bank, int n_data )
671inline void namcos11_state::bankswitch_rom64( address_space &space, const char *bank, int n_data )
668672{
669   namcos11_state *state = space.machine().driver_data<namcos11_state>();
670
671673   /* todo: verify behaviour */
672   state->membank( bank )->set_entry( ( ( ( ( n_data & 0xc0 ) >> 3 ) + ( n_data & 0x07 ) ) ^ state->m_n_bankoffset ) );
674   membank( bank )->set_entry( ( ( ( ( n_data & 0xc0 ) >> 3 ) + ( n_data & 0x07 ) ) ^ m_n_bankoffset ) );
673675}
674676
675677WRITE32_MEMBER(namcos11_state::bankswitch_rom64_w)
676678{
677   verboselog( machine(), 2, "bankswitch_rom64_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
679   verboselog(2, "bankswitch_rom64_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
678680
679681   if( ACCESSING_BITS_0_15 )
680682   {
r21058r21059
695697      output_set_value( "recoil0", !( data & 0x02 ) );
696698      output_set_value( "recoil1", !( data & 0x01 ) );
697699
698      verboselog( machine(), 1, "lightgun_w: outputs (%08x %08x)\n", data, mem_mask );
700      verboselog(1, "lightgun_w: outputs (%08x %08x)\n", data, mem_mask );
699701   }
700702   if( ACCESSING_BITS_16_31 )
701703   {
702      verboselog( machine(), 2, "lightgun_w: start reading (%08x %08x)\n", data, mem_mask );
704      verboselog(2, "lightgun_w: start reading (%08x %08x)\n", data, mem_mask );
703705   }
704706}
705707
r21058r21059
721723      data = ( ioport( "GUN2Y" )->read() ) | ( ( ioport( "GUN2Y" )->read() + 1 ) << 16 );
722724      break;
723725   }
724   verboselog( machine(), 2, "lightgun_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
726   verboselog(2, "lightgun_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
725727   return data;
726728}
727729
r21058r21059
867869   COMBINE_DATA(&m_su_83);
868870}
869871
870static void namcos11_init_common(running_machine &machine, int n_daughterboard)
872void namcos11_state::namcos11_init_common(int n_daughterboard)
871873{
872   namcos11_state *state = machine.driver_data<namcos11_state>();
873874
874875   // C76 idle skipping, large speedboost
875876   if (C76_SPEEDUP)
876877   {
877      state->save_item( NAME(state->m_su_83) );
878      machine.device("c76")->memory().space(AS_PROGRAM).install_readwrite_handler(0x82, 0x83, read16_delegate(FUNC(namcos11_state::c76_speedup_r),state), write16_delegate(FUNC(namcos11_state::c76_speedup_w),state));
878      save_item( NAME(m_su_83) );
879      machine().device("c76")->memory().space(AS_PROGRAM).install_readwrite_handler(0x82, 0x83, read16_delegate(FUNC(namcos11_state::c76_speedup_r),this), write16_delegate(FUNC(namcos11_state::c76_speedup_w),this));
879880   }
880881
881882   if (!n_daughterboard)
882883   {
883      machine.device("maincpu")->memory().space(AS_PROGRAM).nop_write(0x1fa10020, 0x1fa1002f);
884      machine().device("maincpu")->memory().space(AS_PROGRAM).nop_write(0x1fa10020, 0x1fa1002f);
884885      return;
885886   }
886887
887888   // init banks
888889   int bank;
889   UINT32 len = machine.root_device().memregion( "user2" )->bytes();
890   UINT8 *rgn = machine.root_device().memregion( "user2" )->base();
890   UINT32 len = memregion( "user2" )->bytes();
891   UINT8 *rgn = memregion( "user2" )->base();
891892
892   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f000000, 0x1f0fffff, "bank1" );
893   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f100000, 0x1f1fffff, "bank2" );
894   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f200000, 0x1f2fffff, "bank3" );
895   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f300000, 0x1f3fffff, "bank4" );
896   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f400000, 0x1f4fffff, "bank5" );
897   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f500000, 0x1f5fffff, "bank6" );
898   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f600000, 0x1f6fffff, "bank7" );
899   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f700000, 0x1f7fffff, "bank8" );
893   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f000000, 0x1f0fffff, "bank1" );
894   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f100000, 0x1f1fffff, "bank2" );
895   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f200000, 0x1f2fffff, "bank3" );
896   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f300000, 0x1f3fffff, "bank4" );
897   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f400000, 0x1f4fffff, "bank5" );
898   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f500000, 0x1f5fffff, "bank6" );
899   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f600000, 0x1f6fffff, "bank7" );
900   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x1f700000, 0x1f7fffff, "bank8" );
900901
901902   for (bank = 0; bank < 8; bank++)
902903   {
903      state->membank(bankname[bank])->configure_entries(0, len / ( 1024 * 1024 ), rgn, 1024 * 1024 );
904      state->membank(bankname[bank])->set_entry(0 );
904      membank(bankname[bank])->configure_entries(0, len / ( 1024 * 1024 ), rgn, 1024 * 1024 );
905      membank(bankname[bank])->set_entry(0 );
905906   }
906907
907908   if (n_daughterboard == 32)
908909   {
909      machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1fa10020, 0x1fa1002f, write32_delegate(FUNC(namcos11_state::bankswitch_rom32_w),state));
910      machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1fa10020, 0x1fa1002f, write32_delegate(FUNC(namcos11_state::bankswitch_rom32_w),this));
910911   }
911912   if (n_daughterboard == 64)
912913   {
913      state->m_n_bankoffset = 0;
914      machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1f080000, 0x1f080003, write32_delegate(FUNC(namcos11_state::bankswitch_rom64_upper_w),state));
915      machine.device("maincpu")->memory().space(AS_PROGRAM).nop_read(0x1fa10020, 0x1fa1002f);
916      machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1fa10020, 0x1fa1002f, write32_delegate(FUNC(namcos11_state::bankswitch_rom64_w),state));
917      state->save_item( NAME(state->m_n_bankoffset) );
914      m_n_bankoffset = 0;
915      machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1f080000, 0x1f080003, write32_delegate(FUNC(namcos11_state::bankswitch_rom64_upper_w),this));
916      machine().device("maincpu")->memory().space(AS_PROGRAM).nop_read(0x1fa10020, 0x1fa1002f);
917      machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1fa10020, 0x1fa1002f, write32_delegate(FUNC(namcos11_state::bankswitch_rom64_w),this));
918      save_item( NAME(m_n_bankoffset) );
918919   }
919920}
920921
921922DRIVER_INIT_MEMBER(namcos11_state,tekken)
922923{
923   namcos11_init_common(machine(), 32);
924   namcos11_init_common(32);
924925}
925926
926927DRIVER_INIT_MEMBER(namcos11_state,tekken2)
927928{
928929   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c406_r),this));
929   namcos11_init_common(machine(), 32);
930   namcos11_init_common(32);
930931}
931932
932933DRIVER_INIT_MEMBER(namcos11_state,souledge)
933934{
934935   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c409_r),this));
935   namcos11_init_common(machine(), 32);
936   namcos11_init_common(32);
936937}
937938
938939DRIVER_INIT_MEMBER(namcos11_state,dunkmnia)
939940{
940941   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c410_r),this));
941   namcos11_init_common(machine(), 32);
942   namcos11_init_common(32);
942943}
943944
944945DRIVER_INIT_MEMBER(namcos11_state,primglex)
945946{
946947   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c411_r),this));
947   namcos11_init_common(machine(), 32);
948   namcos11_init_common(32);
948949}
949950
950951DRIVER_INIT_MEMBER(namcos11_state,xevi3dg)
951952{
952953   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c430_r),this));
953   namcos11_init_common(machine(), 32);
954   namcos11_init_common(32);
954955}
955956
956957DRIVER_INIT_MEMBER(namcos11_state,danceyes)
957958{
958959   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c431_r),this));
959   namcos11_init_common(machine(), 32);
960   namcos11_init_common(32);
960961}
961962
962963DRIVER_INIT_MEMBER(namcos11_state,pocketrc)
r21058r21059
965966   machine().device("c76")->memory().space(AS_IO).install_read_handler(M37710_ADC1_L, M37710_ADC1_L, read8_delegate(FUNC(namcos11_state::pocketrc_gas_r),this));
966967
967968   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c432_r),this));
968   namcos11_init_common(machine(), 32);
969   namcos11_init_common(32);
969970}
970971
971972DRIVER_INIT_MEMBER(namcos11_state,starswep)
972973{
973974   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c442_r),this));
974   namcos11_init_common(machine(), 0);
975   namcos11_init_common(0);
975976}
976977
977978DRIVER_INIT_MEMBER(namcos11_state,myangel3)
978979{
979980   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c443_r),this));
980   namcos11_init_common(machine(), 64);
981   namcos11_init_common(64);
981982}
982983
983984DRIVER_INIT_MEMBER(namcos11_state,ptblank2ua)
984985{
985986   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler( 0x1fa20000, 0x1fa2ffff, read32_delegate(FUNC(namcos11_state::keycus_c443_r),this));
986   namcos11_init_common(machine(), 64);
987   namcos11_init_common(64);
987988
988989   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x1f788000, 0x1f788003, write32_delegate(FUNC(namcos11_state::lightgun_w),this));
989990   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler (0x1f780000, 0x1f78000f, read32_delegate(FUNC(namcos11_state::lightgun_r),this));
trunk/src/mame/drivers/taitotz.c
r21058r21059
614614   DECLARE_READ8_MEMBER(tlcs_ide1_r);
615615   DECLARE_WRITE8_MEMBER(tlcs_ide1_w);
616616   DECLARE_WRITE_LINE_MEMBER(ide_interrupt);
617   void taitotz_exit();
618   void draw_tile(taitotz_state *state, UINT32 pos, UINT32 tile);
619   UINT32 video_mem_r(taitotz_state *state, UINT32 address);
620   void video_mem_w(taitotz_state *state, UINT32 address, UINT32 data);
621   UINT32 video_reg_r(taitotz_state *state, UINT32 reg);
622   void video_reg_w(taitotz_state *state, UINT32 reg, UINT32 data);
623   void init_taitotz_152();
624   void init_taitotz_111a();
617625};
618626
619627/*
620static void taitotz_exit(running_machine &machine)
628void taitotz_state::taitotz_exit()
621629{
622630
623    taitotz_state *state = machine.driver_data<taitotz_state>();
624631
625632    FILE *file;
626633    int i;
r21058r21059
628635    file = fopen("screen_ram.bin","wb");
629636    for (i=0; i < 0x200000; i++)
630637    {
631        fputc((UINT8)(state->m_screen_ram[i] >> 24), file);
632        fputc((UINT8)(state->m_screen_ram[i] >> 16), file);
633        fputc((UINT8)(state->m_screen_ram[i] >> 8), file);
634        fputc((UINT8)(state->m_screen_ram[i] >> 0), file);
638        fputc((UINT8)(m_screen_ram[i] >> 24), file);
639        fputc((UINT8)(m_screen_ram[i] >> 16), file);
640        fputc((UINT8)(m_screen_ram[i] >> 8), file);
641        fputc((UINT8)(m_screen_ram[i] >> 0), file);
635642    }
636643    fclose(file);
637644
638645    file = fopen("frame_ram.bin","wb");
639646    for (i=0; i < 0x80000; i++)
640647    {
641        fputc((UINT8)(state->m_frame_ram[i] >> 24), file);
642        fputc((UINT8)(state->m_frame_ram[i] >> 16), file);
643        fputc((UINT8)(state->m_frame_ram[i] >> 8), file);
644        fputc((UINT8)(state->m_frame_ram[i] >> 0), file);
648        fputc((UINT8)(m_frame_ram[i] >> 24), file);
649        fputc((UINT8)(m_frame_ram[i] >> 16), file);
650        fputc((UINT8)(m_frame_ram[i] >> 8), file);
651        fputc((UINT8)(m_frame_ram[i] >> 0), file);
645652    }
646653    fclose(file);
647654
648655    file = fopen("texture_ram.bin","wb");
649656    for (i=0; i < 0x800000; i++)
650657    {
651        fputc((UINT8)(state->m_texture_ram[i] >> 24), file);
652        fputc((UINT8)(state->m_texture_ram[i] >> 16), file);
653        fputc((UINT8)(state->m_texture_ram[i] >> 8), file);
654        fputc((UINT8)(state->m_texture_ram[i] >> 0), file);
658        fputc((UINT8)(m_texture_ram[i] >> 24), file);
659        fputc((UINT8)(m_texture_ram[i] >> 16), file);
660        fputc((UINT8)(m_texture_ram[i] >> 8), file);
661        fputc((UINT8)(m_texture_ram[i] >> 0), file);
655662    }
656663    fclose(file);
657664
r21058r21059
13961403   return 0;
13971404}
13981405
1399static void draw_tile(taitotz_state *state, UINT32 pos, UINT32 tile)
1406void taitotz_state::draw_tile(taitotz_state *state, UINT32 pos, UINT32 tile)
14001407{
14011408   int tileu = (tile & 0x1f) * 16;
14021409   int tilev = ((tile >> 5)) * 16;
r21058r21059
14041411   int tilex = (pos & 0x1f) * 16;
14051412   int tiley = ((pos >> 5) & 0x1f) * 16;
14061413
1407   UINT16 *src_tile = (UINT16*)&state->m_screen_ram[0x180000];
1408   UINT16 *dst = (UINT16*)&state->m_screen_ram[state->m_scr_base];
1414   UINT16 *src_tile = (UINT16*)&m_screen_ram[0x180000];
1415   UINT16 *dst = (UINT16*)&m_screen_ram[m_scr_base];
14091416
14101417   int v = tilev;
14111418
r21058r21059
14381445    batlgr2 into 0x9e0000
14391446*/
14401447
1441static UINT32 video_mem_r(taitotz_state *state, UINT32 address)
1448UINT32 taitotz_state::video_mem_r(taitotz_state *state, UINT32 address)
14421449{
14431450   if (address >= 0x800000 && address < 0x1000000)
14441451   {
1445      return state->m_screen_ram[address - 0x800000];
1452      return m_screen_ram[address - 0x800000];
14461453   }
14471454   else if (address >= 0x1000000 && address < 0x1800000)
14481455   {
1449      return state->m_texture_ram[address - 0x1000000];
1456      return m_texture_ram[address - 0x1000000];
14501457   }
14511458   else if (address >= 0x1800000 && address < 0x1880000)
14521459   {
1453      return state->m_frame_ram[address - 0x1800000];
1460      return m_frame_ram[address - 0x1800000];
14541461   }
14551462   else
14561463   {
r21058r21059
14591466   }
14601467}
14611468
1462static void video_mem_w(taitotz_state *state, UINT32 address, UINT32 data)
1469void taitotz_state::video_mem_w(taitotz_state *state, UINT32 address, UINT32 data)
14631470{
14641471   if (address >= 0x800000 && address < 0x1000000)
14651472   {
1466      state->m_screen_ram[address - 0x800000] = data;
1473      m_screen_ram[address - 0x800000] = data;
14671474   }
14681475   else if (address >= 0x1000000 && address < 0x1800000)
14691476   {
1470      state->m_texture_ram[address - 0x1000000] = data;
1477      m_texture_ram[address - 0x1000000] = data;
14711478   }
14721479   else if (address >= 0x1800000 && address < 0x1880000)
14731480   {
1474      state->m_frame_ram[address - 0x1800000] = data;
1481      m_frame_ram[address - 0x1800000] = data;
14751482   }
14761483   else
14771484   {
r21058r21059
14791486   }
14801487}
14811488
1482static UINT32 video_reg_r(taitotz_state *state, UINT32 reg)
1489UINT32 taitotz_state::video_reg_r(taitotz_state *state, UINT32 reg)
14831490{
14841491   switch ((reg >> 28) & 0xf)
14851492   {
r21058r21059
14871494      {
14881495         if (reg == 0x10000105)      // Gets spammed a lot. Probably a status register.
14891496         {
1490            state->m_reg105 ^= 0xffffffff;
1491            return state->m_reg105;
1497            m_reg105 ^= 0xffffffff;
1498            return m_reg105;
14921499         }
14931500
14941501         logerror("video_reg_r: reg: %08X\n", reg);
r21058r21059
15031510
15041511         if (subreg < 0x10)
15051512         {
1506            return state->m_video_unk_reg[subreg];
1513            return m_video_unk_reg[subreg];
15071514         }
15081515         break;
15091516      }
r21058r21059
15421549video_reg_w: r: 20000004 d: 00000000
15431550*/
15441551
1545static void video_reg_w(taitotz_state *state, UINT32 reg, UINT32 data)
1552void taitotz_state::video_reg_w(taitotz_state *state, UINT32 reg, UINT32 data)
15461553{
15471554   switch ((reg >> 28) & 0xf)
15481555   {
r21058r21059
15631570         int subreg = reg & 0xfffffff;
15641571         if (subreg < 0x10)
15651572         {
1566            state->m_video_unk_reg[subreg] = data;
1573            m_video_unk_reg[subreg] = data;
15671574         }
15681575         logerror("video_reg_w: reg: %08X data: %08X\n", reg, data);
15691576         break;
r21058r21059
15771584      }
15781585   case 0xb:       // RAM write?
15791586      {
1580         video_mem_w(state, state->m_video_ram_ptr, data);
1581         state->m_video_ram_ptr++;
1587         video_mem_w(state, m_video_ram_ptr, data);
1588         m_video_ram_ptr++;
15821589         break;
15831590      }
15841591   default:
r21058r21059
25962603
25972604
25982605// Init for BIOS v1.52
2599static void init_taitotz_152(running_machine &machine)
2606void taitotz_state::init_taitotz_152()
26002607{
2601   UINT32 *rom = (UINT32*)machine.root_device().memregion("user1")->base();
2608   UINT32 *rom = (UINT32*)machine().root_device().memregion("user1")->base();
26022609   rom[(0x2c87c^4)/4] = 0x38600000;    // skip sound load timeout...
26032610//  rom[(0x2c620^4)/4] = 0x48000014;    // ID check skip (not needed with correct serial number)
26042611}
26052612
26062613// Init for BIOS 1.11a
2607static void init_taitotz_111a(running_machine &machine)
2614void taitotz_state::init_taitotz_111a()
26082615{
2609   UINT32 *rom = (UINT32*)machine.root_device().memregion("user1")->base();
2616   UINT32 *rom = (UINT32*)machine().root_device().memregion("user1")->base();
26102617   rom[(0x2b748^4)/4] = 0x480000b8;    // skip sound load timeout
26112618}
26122619
r21058r21059
26242631
26252632DRIVER_INIT_MEMBER(taitotz_state,landhigh)
26262633{
2627   init_taitotz_152(machine());
2634   init_taitotz_152();
26282635
26292636   m_hdd_serial_number = LANDHIGH_HDD_SERIAL;
26302637
r21058r21059
26352642
26362643DRIVER_INIT_MEMBER(taitotz_state,batlgear)
26372644{
2638   init_taitotz_111a(machine());
2645   init_taitotz_111a();
26392646
26402647   // unknown, not used by BIOS 1.11a
26412648   m_hdd_serial_number = NULL;
r21058r21059
26472654
26482655DRIVER_INIT_MEMBER(taitotz_state,batlgr2)
26492656{
2650   init_taitotz_152(machine());
2657   init_taitotz_152();
26512658
26522659   m_hdd_serial_number = BATLGR2_HDD_SERIAL;
26532660
r21058r21059
26582665
26592666DRIVER_INIT_MEMBER(taitotz_state,batlgr2a)
26602667{
2661   init_taitotz_152(machine());
2668   init_taitotz_152();
26622669
26632670   m_hdd_serial_number = BATLGR2A_HDD_SERIAL;
26642671
r21058r21059
26692676
26702677DRIVER_INIT_MEMBER(taitotz_state,pwrshovl)
26712678{
2672   init_taitotz_111a(machine());
2679   init_taitotz_111a();
26732680
26742681   // unknown, not used by BIOS 1.11a
26752682   m_hdd_serial_number = NULL;
r21058r21059
26812688
26822689DRIVER_INIT_MEMBER(taitotz_state,raizpin)
26832690{
2684   init_taitotz_152(machine());
2691   init_taitotz_152();
26852692
26862693   m_hdd_serial_number = RAIZPIN_HDD_SERIAL;
26872694
trunk/src/mame/drivers/halleys.c
r21058r21059
269269   TIMER_CALLBACK_MEMBER(blitter_reset);
270270   TIMER_DEVICE_CALLBACK_MEMBER(halleys_scanline);
271271   TIMER_DEVICE_CALLBACK_MEMBER(benberob_scanline);
272   void halleys_decode_rgb(UINT32 *r, UINT32 *g, UINT32 *b, int addr, int data);
273   void copy_scroll_op(bitmap_ind16 &bitmap, UINT16 *source, int sx, int sy);
274   void copy_scroll_xp(bitmap_ind16 &bitmap, UINT16 *source, int sx, int sy);
275   void copy_fixed_xp(bitmap_ind16 &bitmap, UINT16 *source);
276   void copy_fixed_2b(bitmap_ind16 &bitmap, UINT16 *source);
277   void filter_bitmap(bitmap_ind16 &bitmap, int mask);
278   void init_common();
272279};
273280
274281
r21058r21059
11591166   }
11601167}
11611168
1162static void halleys_decode_rgb(running_machine &machine, UINT32 *r, UINT32 *g, UINT32 *b, int addr, int data)
1169void halleys_state::halleys_decode_rgb(UINT32 *r, UINT32 *g, UINT32 *b, int addr, int data)
11631170{
11641171/*
11651172    proms contain:
11661173        00 00 00 00 c5 0b f3 17 fd cf 1f ef df bf 7f ff
11671174        00 00 00 00 01 61 29 26 0b f5 e2 17 57 fb cf f7
11681175*/
1169   halleys_state *state = machine.driver_data<halleys_state>();
11701176   int latch1_273, latch2_273;
11711177   UINT8 *sram_189;
11721178   UINT8 *prom_6330;
r21058r21059
11741180   int bit0, bit1, bit2, bit3, bit4;
11751181
11761182   // the four 16x4-bit SN74S189 SRAM chips are assumed be the game's 32-byte palette RAM
1177   sram_189 = state->m_generic_paletteram_8;
1183   sram_189 = m_generic_paletteram_8;
11781184
11791185   // each of the three 32-byte 6330 PROM is wired to an RGB component output
1180   prom_6330 = state->memregion("proms")->base();
1186   prom_6330 = memregion("proms")->base();
11811187
11821188   // latch1 holds 8 bits from the selected palette RAM address
11831189   latch1_273 = sram_189[addr];
r21058r21059
12291235   palette_set_color(machine(), offset+SP_ALPHA, MAKE_RGB(r, g, b));
12301236   palette_set_color(machine(), offset+SP_COLLD, MAKE_RGB(r, g, b));
12311237
1232   halleys_decode_rgb(machine(), &r, &g, &b, offset, 0);
1238   halleys_decode_rgb(&r, &g, &b, offset, 0);
12331239   palette_set_color(machine(), offset+0x20, MAKE_RGB(r, g, b));
12341240}
12351241
r21058r21059
12631269}
12641270
12651271
1266static void copy_scroll_op(bitmap_ind16 &bitmap, UINT16 *source, int sx, int sy)
1272void halleys_state::copy_scroll_op(bitmap_ind16 &bitmap, UINT16 *source, int sx, int sy)
12671273{
12681274//--------------------------------------------------------------------------
12691275
r21058r21059
13001306}
13011307
13021308
1303static void copy_scroll_xp(bitmap_ind16 &bitmap, UINT16 *source, int sx, int sy)
1309void halleys_state::copy_scroll_xp(bitmap_ind16 &bitmap, UINT16 *source, int sx, int sy)
13041310{
13051311//--------------------------------------------------------------------------
13061312
r21058r21059
13581364
13591365
13601366
1361static void copy_fixed_xp(bitmap_ind16 &bitmap, UINT16 *source)
1367void halleys_state::copy_fixed_xp(bitmap_ind16 &bitmap, UINT16 *source)
13621368{
13631369   UINT16 *esi, *edi;
13641370   int dst_pitch, ecx, edx;
r21058r21059
13931399}
13941400
13951401
1396static void copy_fixed_2b(bitmap_ind16 &bitmap, UINT16 *source)
1402void halleys_state::copy_fixed_2b(bitmap_ind16 &bitmap, UINT16 *source)
13971403{
13981404   UINT16 *esi, *edi;
13991405   int dst_pitch, ecx, edx;
r21058r21059
14401446}
14411447
14421448
1443static void filter_bitmap(running_machine &machine, bitmap_ind16 &bitmap, int mask)
1449void halleys_state::filter_bitmap(bitmap_ind16 &bitmap, int mask)
14441450{
1445   halleys_state *state = machine.driver_data<halleys_state>();
14461451   int dst_pitch;
14471452
14481453   UINT32 *pal_ptr, *edi;
14491454   int esi, eax, ebx, ecx, edx;
14501455
1451   pal_ptr = state->m_internal_palette;
1456   pal_ptr = m_internal_palette;
14521457   esi = mask | 0xffffff00;
14531458   edi = (UINT32*)&bitmap.pix16(VIS_MINY, VIS_MINX + CLIP_W);
14541459   dst_pitch = bitmap.rowpixels() >> 1;
r21058r21059
15041509   // HALF-HACK: apply RGB filter when the following conditions are met
15051510   i = m_io_ram[0xa0];
15061511   j = m_io_ram[0xa1];
1507   if (m_io_ram[0x2b] && (i>0xc6 && i<0xfe) && (j==0xc0 || j==0xed)) filter_bitmap(machine(), bitmap, i);
1512   if (m_io_ram[0x2b] && (i>0xc6 && i<0xfe) && (j==0xc0 || j==0xed)) filter_bitmap(bitmap, i);
15081513   return 0;
15091514}
15101515
r21058r21059
21482153//**************************************************************************
21492154// Driver Initializations
21502155
2151static void init_common(running_machine &machine)
2156void halleys_state::init_common()
21522157{
2153   halleys_state *state = machine.driver_data<halleys_state>();
21542158   UINT8 *buf, *rom;
21552159   int addr, i;
21562160   UINT8 al, ah, dl, dh;
21572161
21582162
21592163   // allocate memory for unpacked graphics
2160   buf = auto_alloc_array(machine, UINT8, 0x100000);
2161   state->m_gfx_plane02 = buf;
2162   state->m_gfx_plane13 = buf + 0x80000;
2164   buf = auto_alloc_array(machine(), UINT8, 0x100000);
2165   m_gfx_plane02 = buf;
2166   m_gfx_plane13 = buf + 0x80000;
21632167
21642168
21652169   // allocate memory for render layers
2166   buf = auto_alloc_array(machine, UINT8, SCREEN_BYTESIZE * MAX_LAYERS);
2167   for (i=0; i<MAX_LAYERS; buf+=SCREEN_BYTESIZE, i++) state->m_render_layer[i] = (UINT16*)buf;
2170   buf = auto_alloc_array(machine(), UINT8, SCREEN_BYTESIZE * MAX_LAYERS);
2171   for (i=0; i<MAX_LAYERS; buf+=SCREEN_BYTESIZE, i++) m_render_layer[i] = (UINT16*)buf;
21682172
21692173
21702174   // allocate memory for pre-processed ROMs
2171   state->m_gfx1_base = auto_alloc_array(machine, UINT8, 0x20000);
2175   m_gfx1_base = auto_alloc_array(machine(), UINT8, 0x20000);
21722176
21732177
21742178   // allocate memory for alpha table
2175   state->m_alpha_table = auto_alloc_array(machine, UINT32, 0x10000);
2179   m_alpha_table = auto_alloc_array(machine(), UINT32, 0x10000);
21762180
21772181
21782182   // allocate memory for internal palette
2179   state->m_internal_palette = auto_alloc_array(machine, UINT32, PALETTE_SIZE);
2183   m_internal_palette = auto_alloc_array(machine(), UINT32, PALETTE_SIZE);
21802184
21812185
21822186   // allocate memory for hardware collision list
2183   state->m_collision_list = auto_alloc_array(machine, UINT8, MAX_SPRITES);
2187   m_collision_list = auto_alloc_array(machine(), UINT8, MAX_SPRITES);
21842188
21852189
21862190   // decrypt main program ROM
2187   rom = state->m_cpu1_base = state->memregion("maincpu")->base();
2188   buf = state->m_gfx1_base;
2191   rom = m_cpu1_base = memregion("maincpu")->base();
2192   buf = m_gfx1_base;
21892193
21902194   for (i=0; i<0x10000; i++)
21912195   {
r21058r21059
21972201
21982202
21992203   // swap graphics ROM addresses and unpack each pixel
2200   rom = machine.root_device().memregion("gfx1")->base();
2201   buf = state->m_gfx_plane02;
2204   rom = memregion("gfx1")->base();
2205   buf = m_gfx_plane02;
22022206
22032207   for (i=0xffff; i>=0; i--)
22042208   {
22052209      al = rom[i];
22062210      ah = rom[i+0x10000];
2207      state->m_gfx1_base[0xffff-i] = al;
2208      state->m_gfx1_base[0x1ffff-i] = ah;
2211      m_gfx1_base[0xffff-i] = al;
2212      m_gfx1_base[0x1ffff-i] = ah;
22092213
22102214      buf[0] = dl = (al    & 1) | (ah<<2 & 4);  dl <<= 1;
22112215      buf[1] = dh = (al>>1 & 1) | (ah<<1 & 4);  dh <<= 1;
r21058r21059
22332237{
22342238   m_game_id = GAME_BENBEROB;
22352239
2236   init_common(machine());
2240   init_common();
22372241
22382242   m_blitter_reset_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(halleys_state::blitter_reset),this));
22392243}
r21058r21059
22442248   m_game_id = GAME_HALLEYS;
22452249   m_collision_detection = 0xb114;
22462250
2247   init_common(machine());
2251   init_common();
22482252}
22492253
22502254DRIVER_INIT_MEMBER(halleys_state,halley87)
r21058r21059
22522256   m_game_id = GAME_HALLEYS;
22532257   m_collision_detection = 0xb10d;
22542258
2255   init_common(machine());
2259   init_common();
22562260}
22572261
22582262
trunk/src/mame/drivers/cyclemb.c
r21058r21059
121121   virtual void palette_init();
122122   UINT32 screen_update_cyclemb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
123123   UINT32 screen_update_skydest(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
124   void cyclemb_draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
125   void cyclemb_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
126   void skydest_draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
127   void skydest_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
128   void skydest_i8741_reset();
124129};
125130
126131
r21058r21059
157162{
158163}
159164
160static void cyclemb_draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
165void cyclemb_state::cyclemb_draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
161166{
162   cyclemb_state *state = screen.machine().driver_data<cyclemb_state>();
163167   gfx_element *gfx = screen.machine().gfx[0];
164168   int x,y,count;
165   UINT8 flip_screen = state->flip_screen();
166
167169   count = 0;
168170
169171   for (y=0;y<32;y++)
170172   {
171173      for (x=0;x<64;x++)
172174      {
173         int attr = state->m_cram[count];
174         int tile = (state->m_vram[count]) | ((attr & 3)<<8);
175         int attr = m_cram[count];
176         int tile = (m_vram[count]) | ((attr & 3)<<8);
175177         int color = ((attr & 0xf8) >> 3) ^ 0x1f;
176178         int odd_line = y & 1 ? 0x40 : 0x00;
177   //      int sx_offs = flip_screen ? 512 : 0
178         int scrollx = ((state->m_vram[(y/2)+odd_line]) + (state->m_cram[(y/2)+odd_line]<<8) + 48) & 0x1ff;
179   //      int sx_offs = flip_screen() ? 512 : 0
180         int scrollx = ((m_vram[(y/2)+odd_line]) + (m_cram[(y/2)+odd_line]<<8) + 48) & 0x1ff;
179181
180182         if(!(attr & 4))
181183            color += 0x20;//screen.machine().rand();
182184
183         if(flip_screen)
185         if(flip_screen())
184186         {
185187            drawgfx_opaque(bitmap,cliprect,gfx,tile,color,1,1,512-(x*8)-scrollx,256-(y*8));
186188            /* wrap-around */
r21058r21059
209211   bank 3
210212   ---- ---x [1] sprite enable flag?
211213   */
212static void cyclemb_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
214void cyclemb_state::cyclemb_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
213215{
214   cyclemb_state *state = screen.machine().driver_data<cyclemb_state>();
215   UINT8 flip_screen = state->flip_screen();
216216   UINT8 col,fx,fy,region;
217217   UINT16 spr_offs,i;
218218   INT16 x,y;
r21058r21059
228228
229229   for(i=0;i<0x40;i+=2)
230230   {
231      y = 0xf1 - state->m_obj2_ram[i];
232      x = state->m_obj2_ram[i+1] - 56;
233      spr_offs = (state->m_obj1_ram[i+0]);
234      spr_offs += ((state->m_obj3_ram[i+0] & 3) << 8);
235      col = (state->m_obj1_ram[i+1] & 0x3f);
236      region = ((state->m_obj3_ram[i] & 0x10) >> 4) + 1;
231      y = 0xf1 - m_obj2_ram[i];
232      x = m_obj2_ram[i+1] - 56;
233      spr_offs = (m_obj1_ram[i+0]);
234      spr_offs += ((m_obj3_ram[i+0] & 3) << 8);
235      col = (m_obj1_ram[i+1] & 0x3f);
236      region = ((m_obj3_ram[i] & 0x10) >> 4) + 1;
237237      if(region == 2)
238238      {
239239         spr_offs >>= 2;
240         //spr_offs += ((state->m_obj3_ram[i+0] & 3) << 5);
240         //spr_offs += ((m_obj3_ram[i+0] & 3) << 5);
241241         y-=16;
242242      }
243243
244      if(state->m_obj3_ram[i+1] & 1)
244      if(m_obj3_ram[i+1] & 1)
245245         x+=256;
246      //if(state->m_obj3_ram[i+1] & 2)
246      //if(m_obj3_ram[i+1] & 2)
247247//              x-=256;
248      fx = (state->m_obj3_ram[i+0] & 4) >> 2;
249      fy = (state->m_obj3_ram[i+0] & 8) >> 3;
248      fx = (m_obj3_ram[i+0] & 4) >> 2;
249      fy = (m_obj3_ram[i+0] & 8) >> 3;
250250
251      if(flip_screen)
251      if(flip_screen())
252252      {
253253         fx = !fx;
254254         fy = !fy;
r21058r21059
258258}
259259
260260
261static void skydest_draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
261void cyclemb_state::skydest_draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
262262{
263   cyclemb_state *state = screen.machine().driver_data<cyclemb_state>();
264263   gfx_element *gfx = screen.machine().gfx[0];
265264   int x,y;
266   //UINT8 flip_screen = state->flip_screen();
267265
268266
269267   for (y=0;y<32;y++)
r21058r21059
272270      {
273271         /* upper bits of the first address of cram seems to be related to colour cycling */
274272
275         int attr = state->m_cram[x+y*64];
276         int tile = (state->m_vram[x+y*64]) | ((attr & 3)<<8);
273         int attr = m_cram[x+y*64];
274         int tile = (m_vram[x+y*64]) | ((attr & 3)<<8);
277275         int color = ((attr & 0xfc) >> 2);
278         int scrollx = state->m_vram[0*64+0];
279         scrollx |= (state->m_cram[0*64+0] & 0x01)<<8;
276         int scrollx = m_vram[0*64+0];
277         scrollx |= (m_cram[0*64+0] & 0x01)<<8;
280278
281         int cycle = (state->m_cram[0*64+0] & 0xf0)>>4;
279         int cycle = (m_cram[0*64+0] & 0xf0)>>4;
282280
283281         color ^= 0x3f;
284282         // hardcoded to thie palette bit?
r21058r21059
288286
289287         int scrolly;
290288         if (x<32)
291            scrolly = state->m_vram[(x)*64+0];
289            scrolly = m_vram[(x)*64+0];
292290         else
293            scrolly = state->m_vram[(x-32)*64+1];
291            scrolly = m_vram[(x-32)*64+1];
294292
295293
296294         drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,x*8+scrollx,((y*8)-scrolly)&0xff);
r21058r21059
313311    ---- ---x [1] sprite enable flag?
314312*/
315313
316static void skydest_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
314void cyclemb_state::skydest_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
317315{
318   cyclemb_state *state = screen.machine().driver_data<cyclemb_state>();
319   UINT8 flip_screen = state->flip_screen();
320316   UINT8 col,fx,fy,region;
321317   UINT16 spr_offs,i;
322318   INT16 x,y;
323319
324//  popmessage("%d %d",state->m_obj2_ram[0x0d], 0xf1 - state->m_obj2_ram[0x0c+1] + 68);
320//  popmessage("%d %d",m_obj2_ram[0x0d], 0xf1 - m_obj2_ram[0x0c+1] + 68);
325321
326322   for(i=0;i<0x80;i+=2)
327323   {
328      y = state->m_obj2_ram[i] - 1;
329      x = state->m_obj2_ram[i+1];
324      y = m_obj2_ram[i] - 1;
325      x = m_obj2_ram[i+1];
330326
331      if(state->m_obj3_ram[i+1] & 1)
327      if(m_obj3_ram[i+1] & 1)
332328         x |= 0x100;
333329
334330         x = 0x138 - x;
335331
336      spr_offs = (state->m_obj1_ram[i+0]);
337      spr_offs += ((state->m_obj3_ram[i+0] & 3) << 8);
338      col = (state->m_obj1_ram[i+1] & 0x3f);
339      region = ((state->m_obj3_ram[i] & 0x10) >> 4) + 1;
332      spr_offs = (m_obj1_ram[i+0]);
333      spr_offs += ((m_obj3_ram[i+0] & 3) << 8);
334      col = (m_obj1_ram[i+1] & 0x3f);
335      region = ((m_obj3_ram[i] & 0x10) >> 4) + 1;
340336      if(region == 2)
341337      {
342338         spr_offs >>= 2;
343      //  spr_offs += ((state->m_obj3_ram[i+0] & 3) << 5);
339      //  spr_offs += ((m_obj3_ram[i+0] & 3) << 5);
344340         x-=16;
345341      }
346342
347343
348      fx = (state->m_obj3_ram[i+0] & 4) >> 2;
349      fy = (state->m_obj3_ram[i+0] & 8) >> 3;
344      fx = (m_obj3_ram[i+0] & 4) >> 2;
345      fy = (m_obj3_ram[i+0] & 8) >> 3;
350346
351      if(flip_screen)
347      if(flip_screen())
352348      {
353349         fx = !fx;
354350         fy = !fy;
r21058r21059
407403   // a bunch of other things are setted here
408404}
409405
410static void skydest_i8741_reset(running_machine &machine)
406void cyclemb_state::skydest_i8741_reset()
411407{
412   cyclemb_state *state = machine.driver_data<cyclemb_state>();
413408
414   state->m_mcu[0].rxd = 0;
415   state->m_mcu[0].txd = 0;
416   state->m_mcu[0].rst = 0;
417   state->m_mcu[0].state = 0;
418   state->m_mcu[0].packet_type = 0;
409   m_mcu[0].rxd = 0;
410   m_mcu[0].txd = 0;
411   m_mcu[0].rst = 0;
412   m_mcu[0].state = 0;
413   m_mcu[0].packet_type = 0;
419414}
420415
421416READ8_MEMBER( cyclemb_state::skydest_i8741_0_r )
r21058r21059
595590
596591void cyclemb_state::machine_reset()
597592{
598   skydest_i8741_reset(machine());
593   skydest_i8741_reset();
599594}
600595
601596

Previous 199869 Revisions Next


© 1997-2024 The MAME Team