Previous 199869 Revisions Next

r20627 Thursday 31st January, 2013 at 09:20:51 UTC by Miodrag Milanović
Move some calls into machine state (no whatsnew)
[src/mame/drivers]alg.c amaticmg.c arcadia.c astinvad.c astrocorp.c atvtrack.c backfire.c beaminv.c berzerk.c bestleag.c bfcobra.c bfm_sc1.c blackt96.c bnstars.c boxer.c

trunk/src/mame/drivers/alg.c
r20626r20627
6060   DECLARE_MACHINE_RESET(alg);
6161   DECLARE_VIDEO_START(alg);
6262   TIMER_CALLBACK_MEMBER(response_timer);
63   void alg_init();
6364};
6465
6566
r20626r20627
687688 *
688689 *************************************/
689690
690static void alg_init(running_machine &machine)
691void alg_state::alg_init()
691692{
692   alg_state *state = machine.driver_data<alg_state>();
693693   static const amiga_machine_interface alg_intf =
694694   {
695695      ANGUS_CHIP_RAM_MASK,
r20626r20627
701701      NULL,
702702      0
703703   };
704   amiga_machine_config(machine, &alg_intf);
704   amiga_machine_config(machine(), &alg_intf);
705705
706706   /* set up memory */
707   state->m_bank1->configure_entry(0, state->m_chip_ram);
708   state->m_bank1->configure_entry(1, machine.root_device().memregion("user1")->base());
707   m_bank1->configure_entry(0, m_chip_ram);
708   m_bank1->configure_entry(1, machine().root_device().memregion("user1")->base());
709709}
710710
711711
r20626r20627
733733   }
734734   auto_free(machine(), original);
735735
736   alg_init(machine());
736   alg_init();
737737}
738738
739739DRIVER_INIT_MEMBER(alg_state,palr3)
r20626r20627
752752   }
753753   auto_free(machine(), original);
754754
755   alg_init(machine());
755   alg_init();
756756}
757757
758758DRIVER_INIT_MEMBER(alg_state,palr6)
r20626r20627
773773   }
774774   auto_free(machine(), original);
775775
776   alg_init(machine());
776   alg_init();
777777}
778778
779779DRIVER_INIT_MEMBER(alg_state,aplatoon)
r20626r20627
793793      memcpy(decrypted + i * 0x1000, rom + shuffle[i] * 0x1000, 0x1000);
794794   memcpy(rom, decrypted, 0x40000);
795795   logerror("decrypt done\n ");
796   alg_init(machine());
796   alg_init();
797797}
798798
799799DRIVER_INIT_MEMBER(alg_state,none)
800800{
801   alg_init(machine());
801   alg_init();
802802}
803803
804804
trunk/src/mame/drivers/bnstars.c
r20626r20627
158158   UINT32 screen_update_bnstars_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
159159   UINT32 screen_update_bnstars_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
160160   TIMER_DEVICE_CALLBACK_MEMBER(ms32_interrupt);
161   void draw_roz(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, int chip);
162   void update_color(int color, int screen);
163   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 *sprram_top, size_t sprram_size, int region);
164   void irq_init();
165   void irq_raise(int level);
161166};
162167
163168
r20626r20627
230235
231236/* ROZ Layers */
232237
233static void draw_roz(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, int chip)
238void bnstars_state::draw_roz(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, int chip)
234239{
235   bnstars_state *state = machine.driver_data<bnstars_state>();
236240   /* TODO: registers 0x40/4 / 0x44/4 and 0x50/4 / 0x54/4 are used, meaning unknown */
237241
238   if (state->m_ms32_roz_ctrl[chip][0x5c/4] & 1)   /* "super" mode */
242   if (m_ms32_roz_ctrl[chip][0x5c/4] & 1)   /* "super" mode */
239243   {
240244      printf("no lineram!\n");
241245      return;
r20626r20627
257261          int start2y = (lineaddr[0x08/4] & 0xffff) | ((lineaddr[0x0c/4] & 3) << 16);
258262          int incxx  = (lineaddr[0x10/4] & 0xffff) | ((lineaddr[0x14/4] & 1) << 16);
259263          int incxy  = (lineaddr[0x18/4] & 0xffff) | ((lineaddr[0x1c/4] & 1) << 16);
260          int startx = (state->m_ms32_roz_ctrl[0x00/4] & 0xffff) | ((state->m_ms32_roz_ctrl[0x04/4] & 3) << 16);
261          int starty = (state->m_ms32_roz_ctrl[0x08/4] & 0xffff) | ((state->m_ms32_roz_ctrl[0x0c/4] & 3) << 16);
262          int offsx  = state->m_ms32_roz_ctrl[0x30/4];
263          int offsy  = state->m_ms32_roz_ctrl[0x34/4];
264          int startx = (m_ms32_roz_ctrl[0x00/4] & 0xffff) | ((m_ms32_roz_ctrl[0x04/4] & 3) << 16);
265          int starty = (m_ms32_roz_ctrl[0x08/4] & 0xffff) | ((m_ms32_roz_ctrl[0x0c/4] & 3) << 16);
266          int offsx  = m_ms32_roz_ctrl[0x30/4];
267          int offsy  = m_ms32_roz_ctrl[0x34/4];
264268
265269          my_clip.min_y = my_clip.max_y = y;
266270
267          offsx += (state->m_ms32_roz_ctrl[0x38/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
268          offsy += (state->m_ms32_roz_ctrl[0x3c/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
271          offsx += (m_ms32_roz_ctrl[0x38/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
272          offsy += (m_ms32_roz_ctrl[0x3c/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
269273
270274          // extend sign
271275          if (start2x & 0x20000) start2x |= ~0x3ffff;
r20626r20627
275279          if (incxx & 0x10000) incxx |= ~0x1ffff;
276280          if (incxy & 0x10000) incxy |= ~0x1ffff;
277281
278          state->m_ms32_roz_tilemap->draw_roz(bitmap, &my_clip,
282          m_ms32_roz_tilemap->draw_roz(bitmap, &my_clip,
279283                  (start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16,
280284                  incxx<<8, incxy<<8, 0, 0,
281285                  1, // Wrap
r20626r20627
287291   }
288292   else    /* "simple" mode */
289293   {
290      int startx = (state->m_ms32_roz_ctrl[chip][0x00/4] & 0xffff) | ((state->m_ms32_roz_ctrl[chip][0x04/4] & 3) << 16);
291      int starty = (state->m_ms32_roz_ctrl[chip][0x08/4] & 0xffff) | ((state->m_ms32_roz_ctrl[chip][0x0c/4] & 3) << 16);
292      int incxx  = (state->m_ms32_roz_ctrl[chip][0x10/4] & 0xffff) | ((state->m_ms32_roz_ctrl[chip][0x14/4] & 1) << 16);
293      int incxy  = (state->m_ms32_roz_ctrl[chip][0x18/4] & 0xffff) | ((state->m_ms32_roz_ctrl[chip][0x1c/4] & 1) << 16);
294      int incyy  = (state->m_ms32_roz_ctrl[chip][0x20/4] & 0xffff) | ((state->m_ms32_roz_ctrl[chip][0x24/4] & 1) << 16);
295      int incyx  = (state->m_ms32_roz_ctrl[chip][0x28/4] & 0xffff) | ((state->m_ms32_roz_ctrl[chip][0x2c/4] & 1) << 16);
296      int offsx  = state->m_ms32_roz_ctrl[chip][0x30/4];
297      int offsy  = state->m_ms32_roz_ctrl[chip][0x34/4];
294      int startx = (m_ms32_roz_ctrl[chip][0x00/4] & 0xffff) | ((m_ms32_roz_ctrl[chip][0x04/4] & 3) << 16);
295      int starty = (m_ms32_roz_ctrl[chip][0x08/4] & 0xffff) | ((m_ms32_roz_ctrl[chip][0x0c/4] & 3) << 16);
296      int incxx  = (m_ms32_roz_ctrl[chip][0x10/4] & 0xffff) | ((m_ms32_roz_ctrl[chip][0x14/4] & 1) << 16);
297      int incxy  = (m_ms32_roz_ctrl[chip][0x18/4] & 0xffff) | ((m_ms32_roz_ctrl[chip][0x1c/4] & 1) << 16);
298      int incyy  = (m_ms32_roz_ctrl[chip][0x20/4] & 0xffff) | ((m_ms32_roz_ctrl[chip][0x24/4] & 1) << 16);
299      int incyx  = (m_ms32_roz_ctrl[chip][0x28/4] & 0xffff) | ((m_ms32_roz_ctrl[chip][0x2c/4] & 1) << 16);
300      int offsx  = m_ms32_roz_ctrl[chip][0x30/4];
301      int offsy  = m_ms32_roz_ctrl[chip][0x34/4];
298302
299      offsx += (state->m_ms32_roz_ctrl[chip][0x38/4] & 1) * 0x400;    // ??? gratia, hayaosi1...
300      offsy += (state->m_ms32_roz_ctrl[chip][0x3c/4] & 1) * 0x400;    // ??? gratia, hayaosi1...
303      offsx += (m_ms32_roz_ctrl[chip][0x38/4] & 1) * 0x400;    // ??? gratia, hayaosi1...
304      offsy += (m_ms32_roz_ctrl[chip][0x3c/4] & 1) * 0x400;    // ??? gratia, hayaosi1...
301305
302306      /* extend sign */
303307      if (startx & 0x20000) startx |= ~0x3ffff;
r20626r20627
307311      if (incyy & 0x10000) incyy |= ~0x1ffff;
308312      if (incyx & 0x10000) incyx |= ~0x1ffff;
309313
310      state->m_ms32_roz_tilemap[chip]->draw_roz(bitmap, cliprect,
314      m_ms32_roz_tilemap[chip]->draw_roz(bitmap, cliprect,
311315            (startx+offsx)<<16, (starty+offsy)<<16,
312316            incxx<<8, incxy<<8, incyx<<8, incyy<<8,
313317            1, // Wrap
r20626r20627
349353}
350354
351355
352static void update_color(running_machine &machine, int color, int screen)
356void bnstars_state::update_color(int color, int screen)
353357{
354   bnstars_state *state = machine.driver_data<bnstars_state>();
355358   int r,g,b;
356359
357   r = ((state->m_ms32_pal_ram[screen][color*2] & 0xff00) >>8 );
358   g = ((state->m_ms32_pal_ram[screen][color*2] & 0x00ff) >>0 );
359   b = ((state->m_ms32_pal_ram[screen][color*2+1] & 0x00ff) >>0 );
360   r = ((m_ms32_pal_ram[screen][color*2] & 0xff00) >>8 );
361   g = ((m_ms32_pal_ram[screen][color*2] & 0x00ff) >>0 );
362   b = ((m_ms32_pal_ram[screen][color*2+1] & 0x00ff) >>0 );
360363
361   palette_set_color(machine,color+screen*0x8000,MAKE_RGB(r,g,b));
364   palette_set_color(machine(),color+screen*0x8000,MAKE_RGB(r,g,b));
362365}
363366
364367WRITE32_MEMBER(bnstars_state::ms32_pal0_ram_w)
365368{
366369   COMBINE_DATA(&m_ms32_pal_ram[0][offset]);
367   update_color(machine(), offset/2, 0);
370   update_color(offset/2, 0);
368371}
369372
370373WRITE32_MEMBER(bnstars_state::ms32_pal1_ram_w)
371374{
372375   COMBINE_DATA(&m_ms32_pal_ram[1][offset]);
373   update_color(machine(), offset/2, 1);
376   update_color(offset/2, 1);
374377}
375378
376379
377380/* SPRITES based on tetrisp2 for now, readd priority bits later */
378static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 *sprram_top, size_t sprram_size, int region)
381void bnstars_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 *sprram_top, size_t sprram_size, int region)
379382{
380   bnstars_state *state = machine.driver_data<bnstars_state>();
381383/***************************************************************************
382384
383385
r20626r20627
418420   int tx, ty, sx, sy, flipx, flipy;
419421   int xsize, ysize, xzoom, yzoom;
420422   int code, attr, color, size, pri, pri_mask;
421   gfx_element *gfx = machine.gfx[region];
423   gfx_element *gfx = machine().gfx[region];
422424
423425   UINT32      *source = sprram_top;
424426   const UINT32    *finish = sprram_top + (sprram_size - 0x10) / 4;
425427
426428
427   if (state->m_ms32_reverse_sprite_order == 1)
429   if (m_ms32_reverse_sprite_order == 1)
428430   {
429431      source  = sprram_top + (sprram_size - 0x10) / 4;
430432      finish  = sprram_top;
431433   }
432434
433435
434   for (;state->m_ms32_reverse_sprite_order ? (source>=finish) : (source<finish); state->m_ms32_reverse_sprite_order ? (source-=4) : (source+=4))
436   for (;m_ms32_reverse_sprite_order ? (source>=finish) : (source<finish); m_ms32_reverse_sprite_order ? (source-=4) : (source+=4))
435437   {
436438      attr    =   source[ 0 ];
437439
r20626r20627
473475
474476      // there are surely also shadows (see gametngk) but how they're enabled we don't know
475477
476      if (state->m_flipscreen)
478      if (m_flipscreen)
477479      {
478480         sx = 320 - ((xsize*xzoom)>>16) - sx;
479481         sy = 224 - ((ysize*yzoom)>>16) - sy;
r20626r20627
497499            color,
498500            flipx, flipy,
499501            sx,sy,
500            xzoom, yzoom, machine.priority_bitmap,pri_mask, 0);
502            xzoom, yzoom, machine().priority_bitmap,pri_mask, 0);
501503   }   /* end sprite loop */
502504}
503505
r20626r20627
544546   m_ms32_bg_tilemap[0]->set_scrolly(0, m_ms32_bg0_scroll[0x0c/4] + m_ms32_bg0_scroll[0x14/4] );
545547   m_ms32_bg_tilemap[0]->draw(bitmap, cliprect, 0,1);
546548
547   draw_roz(machine(),bitmap,cliprect,2,0);
549   draw_roz(bitmap,cliprect,2,0);
548550
549551   m_ms32_tx_tilemap[0]->set_scrollx(0, m_ms32_tx0_scroll[0x00/4] + m_ms32_tx0_scroll[0x08/4] + 0x18);
550552   m_ms32_tx_tilemap[0]->set_scrolly(0, m_ms32_tx0_scroll[0x0c/4] + m_ms32_tx0_scroll[0x14/4]);
551553   m_ms32_tx_tilemap[0]->draw(bitmap, cliprect, 0,4);
552554
553555
554   draw_sprites(machine(),bitmap,cliprect, m_ms32_spram, 0x20000, 0);
556   draw_sprites(bitmap,cliprect, m_ms32_spram, 0x20000, 0);
555557
556558   return 0;
557559}
r20626r20627
567569   m_ms32_bg_tilemap[1]->set_scrolly(0, m_ms32_bg1_scroll[0x0c/4] + m_ms32_bg1_scroll[0x14/4] );
568570   m_ms32_bg_tilemap[1]->draw(bitmap, cliprect, 0,1);
569571
570   draw_roz(machine(),bitmap,cliprect,2,1);
572   draw_roz(bitmap,cliprect,2,1);
571573
572574   m_ms32_tx_tilemap[1]->set_scrollx(0, m_ms32_tx1_scroll[0x00/4] + m_ms32_tx1_scroll[0x08/4] + 0x18);
573575   m_ms32_tx_tilemap[1]->set_scrolly(0, m_ms32_tx1_scroll[0x0c/4] + m_ms32_tx1_scroll[0x14/4]);
574576   m_ms32_tx_tilemap[1]->draw(bitmap, cliprect, 0,4);
575577
576   draw_sprites(machine(),bitmap,cliprect, m_ms32_spram+(0x20000/4), 0x20000, 4);
578   draw_sprites(bitmap,cliprect, m_ms32_spram+(0x20000/4), 0x20000, 4);
577579
578580   return 0;
579581}
r20626r20627
13341336   return i;
13351337}
13361338
1337static void irq_init(running_machine &machine)
1339void bnstars_state::irq_init()
13381340{
1339   bnstars_state *state = machine.driver_data<bnstars_state>();
1340   state->m_irqreq = 0;
1341   machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
1342   machine.device("maincpu")->execute().set_irq_acknowledge_callback(irq_callback);
1341   m_irqreq = 0;
1342   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
1343   machine().device("maincpu")->execute().set_irq_acknowledge_callback(irq_callback);
13431344}
13441345
1345static void irq_raise(running_machine &machine, int level)
1346void bnstars_state::irq_raise(int level)
13461347{
1347   bnstars_state *state = machine.driver_data<bnstars_state>();
1348   state->m_irqreq |= (1<<level);
1349   machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
1348   m_irqreq |= (1<<level);
1349   machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
13501350}
13511351
13521352/* TODO: fix this arrangement (derived from old deprecat lib) */
13531353TIMER_DEVICE_CALLBACK_MEMBER(bnstars_state::ms32_interrupt)
13541354{
13551355   int scanline = param;
1356   if( scanline == 0 ) irq_raise(machine(), 10);
1357   if( scanline == 8)  irq_raise(machine(), 9);
1356   if( scanline == 0 ) irq_raise(10);
1357   if( scanline == 8)  irq_raise(9);
13581358   /* hayaosi1 needs at least 12 IRQ 0 per frame to work (see code at FFE02289)
13591359      kirarast needs it too, at least 8 per frame, but waits for a variable amount
13601360      47pi2 needs ?? per frame (otherwise it hangs when you lose)
r20626r20627
13631363      desertwr
13641364      p47aces
13651365      */
1366   if( (scanline % 8) == 0 && scanline <= 224 ) irq_raise(machine(), 0);
1366   if( (scanline % 8) == 0 && scanline <= 224 ) irq_raise(0);
13671367}
13681368
13691369void bnstars_state::machine_reset()
13701370{
1371   irq_init(machine());
1371   irq_init();
13721372}
13731373
13741374
trunk/src/mame/drivers/arcadia.c
r20626r20627
7979   DECLARE_DRIVER_INIT(airh);
8080   DECLARE_DRIVER_INIT(ldrba);
8181   DECLARE_DRIVER_INIT(socc);
82   void arcadia_init();
83   inline void generic_decode(const char *tag, int bit7, int bit6, int bit5, int bit4, int bit3, int bit2, int bit1, int bit0);
8284};
8385
8486
r20626r20627
764766 *
765767 *************************************/
766768
767INLINE void generic_decode(running_machine &machine, const char *tag, int bit7, int bit6, int bit5, int bit4, int bit3, int bit2, int bit1, int bit0)
769void arcadia_amiga_state::generic_decode(const char *tag, int bit7, int bit6, int bit5, int bit4, int bit3, int bit2, int bit1, int bit0)
768770{
769   UINT16 *rom = (UINT16 *)machine.root_device().memregion(tag)->base();
771   UINT16 *rom = (UINT16 *)machine().root_device().memregion(tag)->base();
770772   int i;
771773
772774   /* only the low byte of ROMs are encrypted in these games */
r20626r20627
775777
776778   #if 0
777779   {
778      UINT8 *ROM = machine.root_device().memregion(tag)->base();
779      int size = machine.root_device().memregion(tag)->bytes();
780      UINT8 *ROM = machine().root_device().memregion(tag)->base();
781      int size = machine().root_device().memregion(tag)->bytes();
780782
781783      FILE *fp;
782784      char filename[256];
783      sprintf(filename,"decrypted_%s", machine.system().name);
785      sprintf(filename,"decrypted_%s", machine().system().name);
784786      fp=fopen(filename, "w+b");
785787      if (fp)
786788      {
r20626r20627
799801 *
800802 *************************************/
801803
802static void arcadia_init(running_machine &machine)
804void arcadia_amiga_state::arcadia_init()
803805{
804   arcadia_amiga_state *state = machine.driver_data<arcadia_amiga_state>();
805806   static const amiga_machine_interface arcadia_intf =
806807   {
807808      ANGUS_CHIP_RAM_MASK,
r20626r20627
814815   UINT16 *biosrom;
815816
816817   /* configure our Amiga setup */
817   amiga_machine_config(machine, &arcadia_intf);
818   amiga_machine_config(machine(), &arcadia_intf);
818819
819820   /* set up memory */
820   state->m_bank1->configure_entry(0, state->m_chip_ram);
821   state->m_bank1->configure_entry(1, machine.root_device().memregion("user1")->base());
821   m_bank1->configure_entry(0, m_chip_ram);
822   m_bank1->configure_entry(1, machine().root_device().memregion("user1")->base());
822823
823824   /* OnePlay bios is encrypted, TenPlay is not */
824   biosrom = (UINT16 *)machine.root_device().memregion("user2")->base();
825   biosrom = (UINT16 *)machine().root_device().memregion("user2")->base();
825826   if (biosrom[0] != 0x4afc)
826      generic_decode(machine, "user2", 6, 1, 0, 2, 3, 4, 5, 7);
827      generic_decode("user2", 6, 1, 0, 2, 3, 4, 5, 7);
827828}
828829
829830
r20626r20627
834835 *
835836 *************************************/
836837
837DRIVER_INIT_MEMBER(arcadia_amiga_state,none)   { arcadia_init(machine()); }
838DRIVER_INIT_MEMBER(arcadia_amiga_state,airh)   { arcadia_init(machine()); generic_decode(machine(), "user3", 5, 0, 2, 4, 7, 6, 1, 3); }
839DRIVER_INIT_MEMBER(arcadia_amiga_state,bowl)   { arcadia_init(machine()); generic_decode(machine(), "user3", 7, 6, 0, 1, 2, 3, 4, 5); }
840DRIVER_INIT_MEMBER(arcadia_amiga_state,dart)   { arcadia_init(machine()); generic_decode(machine(), "user3", 4, 0, 7, 6, 3, 1, 2, 5); }
841DRIVER_INIT_MEMBER(arcadia_amiga_state,ldrba)  { arcadia_init(machine()); generic_decode(machine(), "user3", 2, 3, 4, 1, 0, 7, 5, 6); }
842DRIVER_INIT_MEMBER(arcadia_amiga_state,ninj)   { arcadia_init(machine()); generic_decode(machine(), "user3", 1, 6, 5, 7, 4, 2, 0, 3); }
843DRIVER_INIT_MEMBER(arcadia_amiga_state,rdwr)   { arcadia_init(machine()); generic_decode(machine(), "user3", 3, 1, 6, 4, 0, 5, 2, 7); }
844DRIVER_INIT_MEMBER(arcadia_amiga_state,sdwr)   { arcadia_init(machine()); generic_decode(machine(), "user3", 6, 3, 4, 5, 2, 1, 0, 7); }
845DRIVER_INIT_MEMBER(arcadia_amiga_state,socc)   { arcadia_init(machine()); generic_decode(machine(), "user3", 0, 7, 1, 6, 5, 4, 3, 2); }
846DRIVER_INIT_MEMBER(arcadia_amiga_state,sprg)   { arcadia_init(machine()); generic_decode(machine(), "user3", 4, 7, 3, 0, 6, 5, 2, 1); }
847DRIVER_INIT_MEMBER(arcadia_amiga_state,xeon)   { arcadia_init(machine()); generic_decode(machine(), "user3", 3, 1, 2, 4, 0, 5, 6, 7); }
838DRIVER_INIT_MEMBER(arcadia_amiga_state,none)   { arcadia_init(); }
839DRIVER_INIT_MEMBER(arcadia_amiga_state,airh)   { arcadia_init(); generic_decode("user3", 5, 0, 2, 4, 7, 6, 1, 3); }
840DRIVER_INIT_MEMBER(arcadia_amiga_state,bowl)   { arcadia_init(); generic_decode("user3", 7, 6, 0, 1, 2, 3, 4, 5); }
841DRIVER_INIT_MEMBER(arcadia_amiga_state,dart)   { arcadia_init(); generic_decode("user3", 4, 0, 7, 6, 3, 1, 2, 5); }
842DRIVER_INIT_MEMBER(arcadia_amiga_state,ldrba)  { arcadia_init(); generic_decode("user3", 2, 3, 4, 1, 0, 7, 5, 6); }
843DRIVER_INIT_MEMBER(arcadia_amiga_state,ninj)   { arcadia_init(); generic_decode("user3", 1, 6, 5, 7, 4, 2, 0, 3); }
844DRIVER_INIT_MEMBER(arcadia_amiga_state,rdwr)   { arcadia_init(); generic_decode("user3", 3, 1, 6, 4, 0, 5, 2, 7); }
845DRIVER_INIT_MEMBER(arcadia_amiga_state,sdwr)   { arcadia_init(); generic_decode("user3", 6, 3, 4, 5, 2, 1, 0, 7); }
846DRIVER_INIT_MEMBER(arcadia_amiga_state,socc)   { arcadia_init(); generic_decode("user3", 0, 7, 1, 6, 5, 4, 3, 2); }
847DRIVER_INIT_MEMBER(arcadia_amiga_state,sprg)   { arcadia_init(); generic_decode("user3", 4, 7, 3, 0, 6, 5, 2, 1); }
848DRIVER_INIT_MEMBER(arcadia_amiga_state,xeon)   { arcadia_init(); generic_decode("user3", 3, 1, 2, 4, 0, 5, 6, 7); }
848849
849850/*************************************
850851 *
trunk/src/mame/drivers/blackt96.c
r20626r20627
151151   TILE_GET_INFO_MEMBER(get_bg7_tile_info);
152152   virtual void video_start();
153153   UINT32 screen_update_blackt96(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
154   void draw_strip(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int column);
155   void draw_page(bitmap_ind16 &bitmap, const rectangle &cliprect, int page);
154156};
155157
156158#define GET_INFO( ram ) \
r20626r20627
200202   m_spriteram[7] = m_spriteram7;
201203}
202204
203static void draw_strip(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int column)
205void blackt96_state::draw_strip(bitmap_ind16 &bitmap, const rectangle &cliprect, int page, int column)
204206{
205   blackt96_state *state = machine.driver_data<blackt96_state>();
206207   /* the very first 'page' in the spriteram contains the x/y positions for each tile strip */
207   gfx_element *gfxbg = machine.gfx[0];
208   gfx_element *gfxspr = machine.gfx[1];
208   gfx_element *gfxbg = machine().gfx[0];
209   gfx_element *gfxspr = machine().gfx[1];
209210
210211   int base = column * (0x80/2);
211212   base += page * 2;
r20626r20627
213214   /* ---- ---- ---x xxxx
214215      xxxx ---y yyyy yyyy */
215216
216   int xx=  ((state->m_spriteram[0][base+0]&0x001f)<<4) | (state->m_spriteram[0][base+1]&0xf000)>>12;
217   int yy = ((state->m_spriteram[0][base+1]&0x1ff));
217   int xx=  ((m_spriteram[0][base+0]&0x001f)<<4) | (m_spriteram[0][base+1]&0xf000)>>12;
218   int yy = ((m_spriteram[0][base+1]&0x1ff));
218219
219220   if (xx&0x100) xx-=0x200;
220221   yy = 0x1ff-yy;
r20626r20627
222223
223224   yy -= 15;
224225
225   UINT16* base2 = state->m_spriteram[page]+column * (0x80/2);
226   UINT16* base2 = m_spriteram[page]+column * (0x80/2);
226227
227228   for (int y=0;y<32;y++)
228229   {
r20626r20627
244245   }
245246}
246247
247static void draw_page(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int page)
248void blackt96_state::draw_page(bitmap_ind16 &bitmap, const rectangle &cliprect, int page)
248249{
249250   for (int strip=0;strip<32;strip++)
250251   {
251      draw_strip(machine, bitmap, cliprect, page, strip);
252      draw_strip(bitmap, cliprect, page, strip);
252253   }
253254}
254255
r20626r20627
256257{
257258   bitmap.fill(get_black_pen(machine()), cliprect);
258259
259   draw_page(machine(), bitmap, cliprect, 2); // bg
260   draw_page(machine(), bitmap, cliprect, 3); // lower pri sprites
261   draw_page(machine(), bitmap, cliprect, 1); // higher pri sprites
260   draw_page(bitmap, cliprect, 2); // bg
261   draw_page(bitmap, cliprect, 3); // lower pri sprites
262   draw_page(bitmap, cliprect, 1); // higher pri sprites
262263
263264
264265   /* Text Layer */
trunk/src/mame/drivers/beaminv.c
r20626r20627
8181   virtual void machine_reset();
8282   UINT32 screen_update_beaminv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8383   TIMER_CALLBACK_MEMBER(interrupt_callback);
84   void create_interrupt_timer();
85   void start_interrupt_timer();
8486};
8587
8688
r20626r20627
114116}
115117
116118
117static void create_interrupt_timer( running_machine &machine )
119void beaminv_state::create_interrupt_timer()
118120{
119   beaminv_state *state = machine.driver_data<beaminv_state>();
120   state->m_interrupt_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(beaminv_state::interrupt_callback),state));
121   m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(beaminv_state::interrupt_callback),this));
121122}
122123
123124
124static void start_interrupt_timer( running_machine &machine )
125void beaminv_state::start_interrupt_timer()
125126{
126   beaminv_state *state = machine.driver_data<beaminv_state>();
127127   int vpos = interrupt_lines[0];
128   state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(vpos));
128   m_interrupt_timer->adjust(machine().primary_screen->time_until_pos(vpos));
129129}
130130
131131
r20626r20627
138138
139139void beaminv_state::machine_start()
140140{
141   create_interrupt_timer(machine());
141   create_interrupt_timer();
142142
143143   m_maincpu = machine().device<cpu_device>("maincpu");
144144
r20626r20627
156156
157157void beaminv_state::machine_reset()
158158{
159   start_interrupt_timer(machine());
159   start_interrupt_timer();
160160
161161   m_controller_select = 0;
162162}
trunk/src/mame/drivers/berzerk.c
r20626r20627
6161   UINT32 screen_update_berzerk(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
6262   TIMER_CALLBACK_MEMBER(irq_callback);
6363   TIMER_CALLBACK_MEMBER(nmi_callback);
64   void vpos_to_vsync_chain_counter(int vpos, UINT8 *counter, UINT8 *v256);
65   int vsync_chain_counter_to_vpos(UINT8 counter, UINT8 v256);
66   void create_irq_timer();
67   void start_irq_timer();
68   void create_nmi_timer();
69   void start_nmi_timer();
70   void get_pens(pen_t *pens);
6471};
6572
6673
r20626r20627
130137 *
131138 *************************************/
132139
133static void vpos_to_vsync_chain_counter(int vpos, UINT8 *counter, UINT8 *v256)
140void berzerk_state::vpos_to_vsync_chain_counter(int vpos, UINT8 *counter, UINT8 *v256)
134141{
135142   /* convert from a vertical position to the actual values on the vertical sync counters */
136143   *v256 = ((vpos < VBEND) || (vpos >= VBSTART));
r20626r20627
149156}
150157
151158
152static int vsync_chain_counter_to_vpos(UINT8 counter, UINT8 v256)
159int berzerk_state::vsync_chain_counter_to_vpos(UINT8 counter, UINT8 v256)
153160{
154161   /* convert from the vertical sync counters to an actual vertical position */
155162   int vpos;
r20626r20627
205212}
206213
207214
208static void create_irq_timer(running_machine &machine)
215void berzerk_state::create_irq_timer()
209216{
210   berzerk_state *state = machine.driver_data<berzerk_state>();
211   state->m_irq_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(berzerk_state::irq_callback),state));
217   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(berzerk_state::irq_callback),this));
212218}
213219
214220
215static void start_irq_timer(running_machine &machine)
221void berzerk_state::start_irq_timer()
216222{
217   berzerk_state *state = machine.driver_data<berzerk_state>();
218223   int vpos = vsync_chain_counter_to_vpos(irq_trigger_counts[0], irq_trigger_v256s[0]);
219   state->m_irq_timer->adjust(machine.primary_screen->time_until_pos(vpos));
224   m_irq_timer->adjust(machine().primary_screen->time_until_pos(vpos));
220225}
221226
222227
r20626r20627
284289}
285290
286291
287static void create_nmi_timer(running_machine &machine)
292void berzerk_state::create_nmi_timer()
288293{
289   berzerk_state *state = machine.driver_data<berzerk_state>();
290   state->m_nmi_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(berzerk_state::nmi_callback),state));
294   m_nmi_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(berzerk_state::nmi_callback),this));
291295}
292296
293297
294static void start_nmi_timer(running_machine &machine)
298void berzerk_state::start_nmi_timer()
295299{
296   berzerk_state *state = machine.driver_data<berzerk_state>();
297300   int vpos = vsync_chain_counter_to_vpos(nmi_trigger_counts[0], nmi_trigger_v256s[0]);
298   state->m_nmi_timer->adjust(machine.primary_screen->time_until_pos(vpos));
301   m_nmi_timer->adjust(machine().primary_screen->time_until_pos(vpos));
299302}
300303
301304
r20626r20627
308311
309312void berzerk_state::machine_start()
310313{
311   create_irq_timer(machine());
312   create_nmi_timer(machine());
314   create_irq_timer();
315   create_nmi_timer();
313316
314317   /* register for state saving */
315318   state_save_register_global(machine(), m_magicram_control);
r20626r20627
334337   set_led_status(machine(), 0, 0);
335338   m_magicram_control = 0;
336339
337   start_irq_timer(machine());
338   start_nmi_timer(machine());
340   start_irq_timer();
341   start_nmi_timer();
339342}
340343
341344
r20626r20627
421424}
422425
423426
424static void get_pens(running_machine &machine, pen_t *pens)
427void berzerk_state::get_pens(pen_t *pens)
425428{
426429   static const int resistances_wg[] = { 750, 0 };
427430   static const int resistances_el[] = { 1.0 / ((1.0 / 750.0) + (1.0 / 360.0)), 0 };
r20626r20627
429432   int color;
430433   double color_weights[2];
431434
432   if (machine.root_device().ioport(MONITOR_TYPE_PORT_TAG)->read() == 0)
435   if (machine().root_device().ioport(MONITOR_TYPE_PORT_TAG)->read() == 0)
433436      compute_resistor_weights(0, 0xff, -1.0,
434437                           2, resistances_wg, color_weights, 0, 270,
435438                           2, resistances_wg, color_weights, 0, 270,
r20626r20627
461464   pen_t pens[NUM_PENS];
462465   offs_t offs;
463466
464   get_pens(machine(), pens);
467   get_pens(pens);
465468
466469   for (offs = 0; offs < m_videoram.bytes(); offs++)
467470   {
trunk/src/mame/drivers/bestleag.c
r20626r20627
5353   virtual void video_start();
5454   UINT32 screen_update_bestleag(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   UINT32 screen_update_bestleaw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
56   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5657};
5758
5859
r20626r20627
118119      include several similiarities with other Playmark games (including
119120      the sprite end code and the data being offset (i.e. spriteram starting from 0x16/2))
120121*/
121static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
122void bestleag_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
122123{
123   bestleag_state *state = machine.driver_data<bestleag_state>();
124   UINT16 *spriteram16 = state->m_spriteram;
124   UINT16 *spriteram16 = m_spriteram;
125125
126126   /*
127127
r20626r20627
131131
132132   int offs;
133133
134   for (offs = 0x16/2;offs < state->m_spriteram.bytes()/2;offs += 4)
134   for (offs = 0x16/2;offs < m_spriteram.bytes()/2;offs += 4)
135135   {
136136      int code = spriteram16[offs+3] & 0xfff;
137137      int color = (spriteram16[offs+2] & 0xf000) >> 12;
r20626r20627
144144         return;
145145
146146      /* it can change sprites color mask like the original set */
147      if(state->m_vregs[0x00/2] & 0x1000)
147      if(m_vregs[0x00/2] & 0x1000)
148148         color &= 7;
149149
150      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
150      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
151151               code,
152152               color,
153153               flipx, 0,
154154               flipx ? (sx+16) : (sx),sy,15);
155155
156      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
156      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
157157               code+1,
158158               color,
159159               flipx, 0,
160160               flipx ? (sx) : (sx+16),sy,15);
161161
162162      /* wraparound x */
163      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
163      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
164164               code,
165165               color,
166166               flipx, 0,
167167               flipx ? (sx+16 - 512) : (sx - 512),sy,15);
168168
169      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
169      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
170170               code+1,
171171               color,
172172               flipx, 0,
r20626r20627
185185
186186   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
187187   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
188   draw_sprites(machine(),bitmap,cliprect);
188   draw_sprites(bitmap,cliprect);
189189   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
190190   return 0;
191191}
r20626r20627
201201
202202   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
203203   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
204   draw_sprites(machine(),bitmap,cliprect);
204   draw_sprites(bitmap,cliprect);
205205   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
206206   return 0;
207207}
trunk/src/mame/drivers/atvtrack.c
r20626r20627
6060#include "cpu/sh4/sh4.h"
6161#include "debugger.h"
6262
63memory_region *nandregion;
64int nandcommand[4], nandoffset[4], nandaddressstep, nandaddress[4];
65UINT32 area1_data[4];
6663
6764//#define SPECIALMODE 1 // Alternate code path
6865
r20626r20627
8683   virtual void machine_reset();
8784   virtual void video_start();
8885   UINT32 screen_update_atvtrack(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
86   inline UINT32 decode64_32(offs_t offset64, UINT64 data, UINT64 mem_mask, offs_t &offset32);
87   void logbinary(UINT32 data,int high,int low);
88   
89   memory_region *m_nandregion;
90   int m_nandcommand[4], m_nandoffset[4], m_nandaddressstep, m_nandaddress[4];
91   UINT32 m_area1_data[4];
92   
8993};
9094
91static void logbinary(UINT32 data,int high=31,int low=0)
95void atvtrack_state::logbinary(UINT32 data,int high=31,int low=0)
9296{
9397   UINT32 s;
9498   int z;
r20626r20627
103107   }
104108}
105109
106static inline UINT32 decode64_32(offs_t offset64, UINT64 data, UINT64 mem_mask, offs_t &offset32)
110inline UINT32 atvtrack_state::decode64_32(offs_t offset64, UINT64 data, UINT64 mem_mask, offs_t &offset32)
107111{
108112   if (ACCESSING_BITS_0_31) {
109113      offset32 = offset64 << 1;
r20626r20627
137141
138142   addr = 0;
139143   dat = decode64_32(offset, data, mem_mask, addr);
140//  old = area1_data[addr];
141   area1_data[addr] = dat;
144//  old = m_area1_data[addr];
145   m_area1_data[addr] = dat;
142146   if (addr == (0x00020000-0x00020000)/4) {
143147      if (data & 4) {
144148         device_execute_interface *exec = dynamic_cast<device_execute_interface *>(machine().device("subcpu"));
r20626r20627
160164   if (addr == 0) {
161165      dat = 0;
162166      for (c = 3;c >= 0;c--) {
163         if (nandcommand[c] <= 0x50) {
164            addr = nandaddress[c]+nandoffset[c];
165            dat = (dat << 8) | nandregion->u8(addr+c);
166            nandoffset[c] += 4;
167         if (m_nandcommand[c] <= 0x50) {
168            addr = m_nandaddress[c]+m_nandoffset[c];
169            dat = (dat << 8) | m_nandregion->u8(addr+c);
170            m_nandoffset[c] += 4;
167171         } else
168172            dat = (dat << 8) | 0xc0;
169173      }
r20626r20627
207211//  dat = decode64_32(offset, data, mem_mask, addr);
208212   if (addr == 0) {
209213      for (c = 0;c < 4;c++) {
210         nandcommand[c] = data & 0xff;
211         if (nandcommand[c] == 0x00) {
212            nandoffset[c] = 0;
213         } else if (nandcommand[c] == 0x01) {
214            nandoffset[c] = 256*4;
215         } else if (nandcommand[c] == 0x50) {
216            nandoffset[c] = 512*4;
217         } else if (nandcommand[c] == 0x90) {
218         } else if (nandcommand[c] == 0xff) {
219         } else if (nandcommand[c] == 0x80) {
220         } else if (nandcommand[c] == 0x60) {
221         } else if (nandcommand[c] == 0x70) {
222         } else if (nandcommand[c] == 0x10) {
223         } else if (nandcommand[c] == 0xd0) {
214         m_nandcommand[c] = data & 0xff;
215         if (m_nandcommand[c] == 0x00) {
216            m_nandoffset[c] = 0;
217         } else if (m_nandcommand[c] == 0x01) {
218            m_nandoffset[c] = 256*4;
219         } else if (m_nandcommand[c] == 0x50) {
220            m_nandoffset[c] = 512*4;
221         } else if (m_nandcommand[c] == 0x90) {
222         } else if (m_nandcommand[c] == 0xff) {
223         } else if (m_nandcommand[c] == 0x80) {
224         } else if (m_nandcommand[c] == 0x60) {
225         } else if (m_nandcommand[c] == 0x70) {
226         } else if (m_nandcommand[c] == 0x10) {
227         } else if (m_nandcommand[c] == 0xd0) {
224228         } else {
225            nandcommand[c] = 0xff;
229            m_nandcommand[c] = 0xff;
226230         }
227231         data=data >> 8;
228232      }
229      nandaddressstep = 0;
233      m_nandaddressstep = 0;
230234   } else
231235      ;
232236}
r20626r20627
253257//  dat = decode64_32(offset, data, mem_mask, addr);
254258   if (addr == 0) {
255259      for (c = 0;c < 4;c++) {
256         if (nandaddressstep == 0) {
257            nandaddress[c] = (data & 0xff)*4;
258         } else if (nandaddressstep == 1) {
259            nandaddress[c] = nandaddress[c]+(data & 0xff)*0x840;
260         } else if (nandaddressstep == 2) {
261            nandaddress[c] = nandaddress[c]+(data & 0xff)*0x84000;
260         if (m_nandaddressstep == 0) {
261            m_nandaddress[c] = (data & 0xff)*4;
262         } else if (m_nandaddressstep == 1) {
263            m_nandaddress[c] = m_nandaddress[c]+(data & 0xff)*0x840;
264         } else if (m_nandaddressstep == 2) {
265            m_nandaddress[c] = m_nandaddress[c]+(data & 0xff)*0x84000;
262266         }
263267         data = data >> 8;
264268      }
265      nandaddressstep++;
269      m_nandaddressstep++;
266270   } else
267271      ;
268272}
r20626r20627
328332{
329333   UINT8 *src, *dst;
330334
331   nandaddressstep = 0;
332   nandregion = machine().root_device().memregion("maincpu");
335   m_nandaddressstep = 0;
336   m_nandregion = machine().root_device().memregion("maincpu");
333337   address_space &as = machine().device("maincpu")->memory().space(AS_PROGRAM);
334338   dst = (UINT8 *)(as.get_write_ptr(0x0c7f0000));
335   src = nandregion->base()+0x10;
339   src = m_nandregion->base()+0x10;
336340   // copy 0x10000 bytes from region "maincpu" offset 0x10 to 0x0c7f0000
337341   memcpy(dst, src, 0x10000);
338342}
trunk/src/mame/drivers/astrocorp.c
r20626r20627
6969   DECLARE_VIDEO_START(astrocorp);
7070   UINT32 screen_update_astrocorp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7171   TIMER_DEVICE_CALLBACK_MEMBER(skilldrp_scanline);
72   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
7273};
7374
7475/***************************************************************************
r20626r20627
106107
107108***************************************************************************/
108109
109static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
110void astrocorp_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
110111{
111   astrocorp_state *state = machine.driver_data<astrocorp_state>();
112   UINT16 *source = state->m_spriteram;
113   UINT16 *finish = state->m_spriteram + state->m_spriteram.bytes() / 2;
112   UINT16 *source = m_spriteram;
113   UINT16 *finish = m_spriteram + m_spriteram.bytes() / 2;
114114
115115   for ( ; source < finish; source += 8 / 2 )
116116   {
r20626r20627
142142            {
143143               for (xwrap = 0 ; xwrap <= 0x200 ; xwrap += 0x200)
144144               {
145                  drawgfx_transpen(bitmap,cliprect, machine.gfx[0],
145                  drawgfx_transpen(bitmap,cliprect, machine().gfx[0],
146146                        code, 0,
147147                        0, 0,
148148                        sx + x * 16 - xwrap, sy + y * 16 - ywrap, 0xff);
r20626r20627
175175   UINT16 now = COMBINE_DATA(&m_draw_sprites);
176176
177177   if (!old && now)
178      draw_sprites(machine(), m_bitmap, machine().primary_screen->visible_area());
178      draw_sprites(m_bitmap, machine().primary_screen->visible_area());
179179}
180180
181181WRITE16_MEMBER(astrocorp_state::astrocorp_eeprom_w)
trunk/src/mame/drivers/amaticmg.c
r20626r20627
455455   UINT32 screen_update_amaticmg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
456456   UINT32 screen_update_amaticmg2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
457457   INTERRUPT_GEN_MEMBER(amaticmg2_irq);
458   void encf(UINT8 ciphertext, int address, UINT8 &plaintext, int &newaddress);
459   void decrypt(int key1, int key2);
458460};
459461
460462
r20626r20627
10601062*       Driver Initialization       *
10611063************************************/
10621064
1063static void encf(UINT8 ciphertext, int address, UINT8 &plaintext, int &newaddress)
1065void amaticmg_state::encf(UINT8 ciphertext, int address, UINT8 &plaintext, int &newaddress)
10641066{
10651067   int aux = address & 0xfff;
10661068   aux = aux ^ (aux>>6);
r20626r20627
10741076   newaddress = (address & ~0xfff) | aux;
10751077}
10761078
1077static void decrypt(running_machine &machine, int key1, int key2)
1079void amaticmg_state::decrypt(int key1, int key2)
10781080{
10791081   UINT8 plaintext;
10801082   int newaddress;
10811083
1082   UINT8 *src = machine.root_device().memregion("mainprg")->base();
1083   UINT8 *dest = machine.root_device().memregion("maincpu")->base();
1084   int len = machine.root_device().memregion("mainprg")->bytes();
1084   UINT8 *src = machine().root_device().memregion("mainprg")->base();
1085   UINT8 *dest = machine().root_device().memregion("maincpu")->base();
1086   int len = machine().root_device().memregion("mainprg")->bytes();
10851087
10861088   for (int i = 0; i < len; i++)
10871089   {
r20626r20627
10921094
10931095DRIVER_INIT_MEMBER(amaticmg_state,ama8000_1_x)
10941096{
1095   decrypt(machine(), 0x4d1, 0xf5);
1097   decrypt(0x4d1, 0xf5);
10961098}
10971099
10981100DRIVER_INIT_MEMBER(amaticmg_state,ama8000_2_i)
10991101{
1100   decrypt(machine(), 0x436, 0x55);
1102   decrypt(0x436, 0x55);
11011103}
11021104
11031105DRIVER_INIT_MEMBER(amaticmg_state,ama8000_2_v)
11041106{
1105   decrypt(machine(), 0x703, 0xaf);
1107   decrypt(0x703, 0xaf);
11061108}
11071109
11081110DRIVER_INIT_MEMBER(amaticmg_state,ama8000_3_o)
11091111{
1110   decrypt(machine(), 0x56e, 0xa7);
1112   decrypt(0x56e, 0xa7);
11111113}
11121114
11131115
trunk/src/mame/drivers/boxer.c
r20626r20627
5252   UINT32 screen_update_boxer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5353   TIMER_CALLBACK_MEMBER(pot_interrupt);
5454   TIMER_CALLBACK_MEMBER(periodic_callback);
55   void draw_boxer( bitmap_ind16 &bitmap, const rectangle &cliprect );
5556};
5657
5758/*************************************
r20626r20627
123124   palette_set_color(machine(),3, MAKE_RGB(0x00,0x00,0x00));
124125}
125126
126static void draw_boxer( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
127void boxer_state::draw_boxer( bitmap_ind16 &bitmap, const rectangle &cliprect )
127128{
128   boxer_state *state = machine.driver_data<boxer_state>();
129129   int n;
130130
131131   for (n = 0; n < 2; n++)
132132   {
133      const UINT8* p = state->memregion(n == 0 ? "user1" : "user2")->base();
133      const UINT8* p = memregion(n == 0 ? "user1" : "user2")->base();
134134
135135      int i, j;
136136
137      int x = 196 - state->m_sprite_ram[0 + 2 * n];
138      int y = 192 - state->m_sprite_ram[1 + 2 * n];
137      int x = 196 - m_sprite_ram[0 + 2 * n];
138      int y = 192 - m_sprite_ram[1 + 2 * n];
139139
140      int l = state->m_sprite_ram[4 + 2 * n] & 15;
141      int r = state->m_sprite_ram[5 + 2 * n] & 15;
140      int l = m_sprite_ram[4 + 2 * n] & 15;
141      int r = m_sprite_ram[5 + 2 * n] & 15;
142142
143143      for (i = 0; i < 8; i++)
144144      {
r20626r20627
149149            code = p[32 * l + 4 * i + j];
150150
151151            drawgfx_transpen(bitmap, cliprect,
152               machine.gfx[n],
152               machine().gfx[n],
153153               code,
154154               0,
155155               code & 0x80, 0,
r20626r20627
159159            code = p[32 * r + 4 * i - j + 3];
160160
161161            drawgfx_transpen(bitmap, cliprect,
162               machine.gfx[n],
162               machine().gfx[n],
163163               code,
164164               0,
165165               !(code & 0x80), 0,
r20626r20627
193193      }
194194   }
195195
196   draw_boxer(machine(), bitmap, cliprect);
196   draw_boxer(bitmap, cliprect);
197197   return 0;
198198}
199199
trunk/src/mame/drivers/bfcobra.c
r20626r20627
302302   UINT32 screen_update_bfcobra(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
303303   INTERRUPT_GEN_MEMBER(timer_irq);
304304   INTERRUPT_GEN_MEMBER(vblank_gen);
305   void RunBlit(address_space &space);
306   void update_irqs();
307   void reset_fdc();
308   void exec_w_phase(UINT8 data);
309   void init_ram();
310   void command_phase(struct fdc_t &fdc, UINT8 data);
305311};
306312
307313
r20626r20627
459465    The Flare One blitter is a simpler design with slightly different parameters
460466    and will require hardware tests to figure everything out correctly.
461467*/
462static void RunBlit(address_space &space)
468void bfcobra_state::RunBlit(address_space &space)
463469{
464470#define BLITPRG_READ(x)     blitter.x = *(blitter_get_addr(space.machine(), blitter.program.addr++))
465471
466   bfcobra_state *state = space.machine().driver_data<bfcobra_state>();
467   struct blitter_t &blitter = state->m_blitter;
472   struct blitter_t &blitter = m_blitter;
468473   int cycles_used = 0;
469474
470475
r20626r20627
873878
874879***************************************************************************/
875880
876static void update_irqs(running_machine &machine)
881void bfcobra_state::update_irqs()
877882{
878   bfcobra_state *state = machine.driver_data<bfcobra_state>();
879   int newstate = state->m_blitter_irq || state->m_vblank_irq || state->m_acia_irq;
883   int newstate = m_blitter_irq || m_vblank_irq || m_acia_irq;
880884
881   if (newstate != state->m_irq_state)
885   if (newstate != m_irq_state)
882886   {
883      state->m_irq_state = newstate;
884      machine.device("maincpu")->execute().set_input_line(0, state->m_irq_state ? ASSERT_LINE : CLEAR_LINE);
887      m_irq_state = newstate;
888      machine().device("maincpu")->execute().set_input_line(0, m_irq_state ? ASSERT_LINE : CLEAR_LINE);
885889   }
886890}
887891
r20626r20627
910914         val = 0x1;
911915
912916         /* TODO */
913         update_irqs(machine());
917         update_irqs();
914918         break;
915919      }
916920      case 0x1C:
r20626r20627
10671071
10681072***************************************************************************/
10691073
1070static void command_phase(struct fdc_t &fdc, UINT8 data);
1071static void exec_w_phase(UINT8 data);
1072//UINT8 exec_r_phase(void);
10731074
10741075/*
10751076    WD37C656C-PL (or equivalent) Floppy Disk Controller
r20626r20627
11021103   SCAN_HIGH_OR_EQUAL = 29
11031104};
11041105
1105static void reset_fdc(running_machine &machine)
1106void bfcobra_state::reset_fdc()
11061107{
1107   bfcobra_state *state = machine.driver_data<bfcobra_state>();
1108   memset(&state->m_fdc, 0, sizeof(state->m_fdc));
1108   memset(&m_fdc, 0, sizeof(m_fdc));
11091109
1110   state->m_fdc.MSR = 0x80;
1111   state->m_fdc.phase = COMMAND;
1110   m_fdc.MSR = 0x80;
1111   m_fdc.phase = COMMAND;
11121112}
11131113
11141114READ8_MEMBER(bfcobra_state::fdctrl_r)
r20626r20627
12151215   }
12161216}
12171217
1218static void command_phase(struct fdc_t &fdc, UINT8 data)
1218void bfcobra_state::command_phase(struct fdc_t &fdc, UINT8 data)
12191219{
12201220   if (fdc.cmd_cnt == 0)
12211221   {
r20626r20627
13031303}
13041304#endif
13051305
1306static void exec_w_phase(UINT8 data)
1306void bfcobra_state::exec_w_phase(UINT8 data)
13071307{
13081308}
13091309
r20626r20627
13331333
13341334   m_bank_data[0] = 1;
13351335   memset(&m_ramdac, 0, sizeof(m_ramdac));
1336   reset_fdc(machine());
1336   reset_fdc();
13371337
13381338   m_irq_state = m_blitter_irq = m_vblank_irq = m_acia_irq = 0;
13391339}
r20626r20627
16041604/*
16051605    Allocate work RAM and video RAM shared by the Z80 and chipset.
16061606*/
1607static void init_ram(running_machine &machine)
1607void bfcobra_state::init_ram()
16081608{
1609   bfcobra_state *state = machine.driver_data<bfcobra_state>();
16101609   /* 768kB work RAM */
1611   state->m_work_ram = auto_alloc_array_clear(machine, UINT8, 0xC0000);
1610   m_work_ram = auto_alloc_array_clear(machine(), UINT8, 0xC0000);
16121611
16131612   /* 128kB video RAM */
1614   state->m_video_ram = auto_alloc_array_clear(machine, UINT8, 0x20000);
1613   m_video_ram = auto_alloc_array_clear(machine(), UINT8, 0x20000);
16151614}
16161615
16171616/*
r20626r20627
16311630WRITE_LINE_MEMBER(bfcobra_state::z80_acia_irq)
16321631{
16331632   m_acia_irq = state;
1634   update_irqs(machine());
1633   update_irqs();
16351634}
16361635
16371636static ACIA6850_INTERFACE( z80_acia_if )
r20626r20627
17331732
17341733   auto_free(machine(), tmp);
17351734
1736   init_ram(machine());
1735   init_ram();
17371736
17381737   m_bank_data[0] = 1;
17391738   m_bank_data[1] = 0;
r20626r20627
17721771INTERRUPT_GEN_MEMBER(bfcobra_state::vblank_gen)
17731772{
17741773   m_vblank_irq = 1;
1775   update_irqs(machine());
1774   update_irqs();
17761775}
17771776
17781777static MACHINE_CONFIG_START( bfcobra, bfcobra_state )
trunk/src/mame/drivers/astinvad.c
r20626r20627
8585   UINT32 screen_update_spaceint(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8686   TIMER_CALLBACK_MEMBER(kamikaze_int_off);
8787   TIMER_CALLBACK_MEMBER(kamizake_int_gen);
88   void plot_byte( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, UINT8 color );
8889};
8990
9091
r20626r20627
154155 *
155156 *************************************/
156157
157static void plot_byte( running_machine &machine, bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, UINT8 color )
158void astinvad_state::plot_byte( bitmap_rgb32 &bitmap, UINT8 y, UINT8 x, UINT8 data, UINT8 color )
158159{
159   astinvad_state *state = machine.driver_data<astinvad_state>();
160160   pen_t fore_pen = MAKE_RGB(pal1bit(color >> 0), pal1bit(color >> 2), pal1bit(color >> 1));
161   UINT8 flip_xor = state->m_screen_flip & 7;
161   UINT8 flip_xor = m_screen_flip & 7;
162162
163163   bitmap.pix32(y, x + (0 ^ flip_xor)) = (data & 0x01) ? fore_pen : RGB_BLACK;
164164   bitmap.pix32(y, x + (1 ^ flip_xor)) = (data & 0x02) ? fore_pen : RGB_BLACK;
r20626r20627
183183      {
184184         UINT8 color = color_prom[((y & 0xf8) << 2) | (x >> 3)] >> (m_screen_flip ? 0 : 4);
185185         UINT8 data = m_videoram[(((y ^ m_screen_flip) + yoffs) << 5) | ((x ^ m_screen_flip) >> 3)];
186         plot_byte(machine(), bitmap, y, x, data, m_screen_red ? 1 : color);
186         plot_byte(bitmap, y, x, data, m_screen_red ? 1 : color);
187187      }
188188
189189   return 0;
r20626r20627
216216      n = ((offs >> 5) & 0xf0) | color;
217217      color = color_prom[n] & 0x07;
218218
219      plot_byte(machine(), bitmap, y, x, data, color);
219      plot_byte(bitmap, y, x, data, color);
220220   }
221221
222222   return 0;
trunk/src/mame/drivers/bfm_sc1.c
r20626r20627
180180   DECLARE_DRIVER_INIT(nocrypt);
181181   virtual void machine_reset();
182182   INTERRUPT_GEN_MEMBER(timer_irq);
183   void sc1_common_init(int reels, int decrypt, int defaultbank);
183184};
184185
185186#define VFD_RESET  0x20
r20626r20627
11521153MACHINE_CONFIG_END
11531154
11541155
1155static void sc1_common_init(running_machine &machine, int reels, int decrypt, int defaultbank)
1156void bfm_sc1_state::sc1_common_init(int reels, int decrypt, int defaultbank)
11561157{
1157   bfm_sc1_state *state = machine.driver_data<bfm_sc1_state>();
11581158   UINT8 i;
11591159
1160   memset(state->m_sc1_Inputs, 0, sizeof(state->m_sc1_Inputs));
1160   memset(m_sc1_Inputs, 0, sizeof(m_sc1_Inputs));
11611161
11621162   // setup n default 96 half step reels ///////////////////////////////////////////
11631163   for ( i = 0; i < reels; i++ )
11641164   {
1165      stepper_config(machine, i, &starpoint_interface_48step);
1165      stepper_config(machine(), i, &starpoint_interface_48step);
11661166   }
1167   if (decrypt) bfm_decode_mainrom(machine,"maincpu", state->m_codec_data);    // decode main rom
1167   if (decrypt) bfm_decode_mainrom(machine(),"maincpu", m_codec_data);    // decode main rom
11681168
1169   state->m_defaultbank = defaultbank;
1169   m_defaultbank = defaultbank;
11701170
11711171}
11721172
r20626r20627
12491249
12501250DRIVER_INIT_MEMBER(bfm_sc1_state,toppoker)
12511251{
1252   sc1_common_init(machine(),3,1, 3);
1252   sc1_common_init(3,1, 3);
12531253   adder2_decode_char_roms(machine()); // decode GFX roms
12541254   MechMtr_config(machine(),8);
12551255   sc1_find_project_string(machine());
r20626r20627
12571257
12581258DRIVER_INIT_MEMBER(bfm_sc1_state,lotse)
12591259{
1260   sc1_common_init(machine(),6,1, 3);
1260   sc1_common_init(6,1, 3);
12611261   MechMtr_config(machine(),8);
12621262   sc1_find_project_string(machine());
12631263}
12641264
12651265DRIVER_INIT_MEMBER(bfm_sc1_state,lotse_bank0)
12661266{
1267   sc1_common_init(machine(),6,1, 0);
1267   sc1_common_init(6,1, 0);
12681268   MechMtr_config(machine(),8);
12691269   sc1_find_project_string(machine());
12701270}
r20626r20627
12721272
12731273DRIVER_INIT_MEMBER(bfm_sc1_state,nocrypt)
12741274{
1275   sc1_common_init(machine(),6,0, 3);
1275   sc1_common_init(6,0, 3);
12761276   MechMtr_config(machine(),8);
12771277   sc1_find_project_string(machine());
12781278}
12791279
12801280DRIVER_INIT_MEMBER(bfm_sc1_state,nocrypt_bank0)
12811281{
1282   sc1_common_init(machine(),6,0, 0);
1282   sc1_common_init(6,0, 0);
12831283   MechMtr_config(machine(),8);
12841284   sc1_find_project_string(machine());
12851285}
r20626r20627
12891289
12901290DRIVER_INIT_MEMBER(bfm_sc1_state,rou029)
12911291{
1292   sc1_common_init(machine(),6,0, 3);
1292   sc1_common_init(6,0, 3);
12931293   MechMtr_config(machine(),8);
12941294   sc1_find_project_string(machine());
12951295}
r20626r20627
12981298
12991299DRIVER_INIT_MEMBER(bfm_sc1_state,clatt)
13001300{
1301   sc1_common_init(machine(),6,1, 3);
1301   sc1_common_init(6,1, 3);
13021302   MechMtr_config(machine(),8);
13031303
13041304   Scorpion1_SetSwitchState(this,3,2,1);
trunk/src/mame/drivers/backfire.c
r20626r20627
8787   UINT32 screen_update_backfire_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8888   UINT32 screen_update_backfire_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8989   INTERRUPT_GEN_MEMBER(deco32_vbl_interrupt);
90   void descramble_sound();
9091};
9192
9293//UINT32 *backfire_180010, *backfire_188010;
r20626r20627
668669   ROM_LOAD( "mbz-06.19l",    0x200000, 0x080000,  CRC(4a38c635) SHA1(7f0fb6a7a4aa6774c04fa38e53ceff8744fe1e9f) )
669670ROM_END
670671
671static void descramble_sound( running_machine &machine )
672void backfire_state::descramble_sound()
672673{
673   UINT8 *rom = machine.root_device().memregion("ymz")->base();
674   UINT8 *rom = machine().root_device().memregion("ymz")->base();
674675   int length = 0x200000; // only the first rom is swapped on backfire!
675   UINT8 *buf1 = auto_alloc_array(machine, UINT8, length);
676   UINT8 *buf1 = auto_alloc_array(machine(), UINT8, length);
676677   UINT32 x;
677678
678679   for (x = 0; x < length; x++)
r20626r20627
691692
692693   memcpy(rom, buf1, length);
693694
694   auto_free(machine, buf1);
695   auto_free(machine(), buf1);
695696}
696697
697698READ32_MEMBER(backfire_state::backfire_speedup_r)
r20626r20627
711712   deco56_decrypt_gfx(machine(), "gfx2"); /* 141 */
712713   deco156_decrypt(machine());
713714   machine().device("maincpu")->set_clock_scale(4.0f); /* core timings aren't accurate */
714   descramble_sound(machine());
715   descramble_sound();
715716   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0170018, 0x017001b, read32_delegate(FUNC(backfire_state::backfire_speedup_r), this));
716717}
717718

Previous 199869 Revisions Next


© 1997-2024 The MAME Team