Previous 199869 Revisions Next

r20932 Monday 11th February, 2013 at 11:18:02 UTC by Miodrag Milanović
Modernization of drivers part 12 (no whatsnew)
[src/mame/audio]mw8080bw.c
[src/mame/drivers]m72.c m92.c macrossp.c madalien.c maygay1b.c mcr.c mcr3.c mcr68.c megasys1.c metro.c mitchell.c ms32.c mw8080bw.c mystston.c
[src/mame/includes]m10.h m107.h m52.h m57.h m58.h m62.h m72.h m90.h m92.h macrossp.h madalien.h mainsnk.h mappy.h marineb.h mario.h markham.h maygay1b.h mcatadv.h mcr.h mcr3.h mcr68.h meadows.h megasys1.h mermaid.h metlclsh.h metro.h mexico86.h midwunit.h midxunit.h mikie.h mitchell.h mjkjidai.h momoko.h mrdo.h mrflea.h mrjong.h ms32.h msisaac.h mugsmash.h munchmo.h mustache.h mw8080bw.h mystston.h
[src/mame/machine]mcr68.c mexico86.c midwunit.c midxunit.c mw8080bw.c
[src/mame/video]m10.c m107.c m52.c m57.c m58.c m62.c m72.c m90.c m92.c macrossp.c madalien.c mainsnk.c mappy.c marineb.c mario.c markham.c mcatadv.c mcr.c mcr3.c mcr68.c meadows.c megasys1.c mermaid.c metlclsh.c metro.c mikie.c mitchell.c mjkjidai.c momoko.c mrdo.c mrflea.c mrjong.c ms32.c msisaac.c mugsmash.c munchmo.c mustache.c mystston.c

trunk/src/mame/drivers/m92.c
r20931r20932
204204#include "sound/okim6295.h"
205205
206206
207#define M92_IRQ_0 ((state->m_irq_vectorbase+0)/4)  /* VBL interrupt */
208#define M92_IRQ_1 ((state->m_irq_vectorbase+4)/4)  /* Sprite buffer complete interrupt */
209#define M92_IRQ_2 ((state->m_irq_vectorbase+8)/4)  /* Raster interrupt */
207#define M92_IRQ_0 ((m_irq_vectorbase+0)/4)  /* VBL interrupt */
208#define M92_IRQ_1 ((m_irq_vectorbase+4)/4)  /* Sprite buffer complete interrupt */
209#define M92_IRQ_2 ((m_irq_vectorbase+8)/4)  /* Raster interrupt */
210210#define M92_IRQ_3 ((m_irq_vectorbase+12)/4) /* Sound cpu interrupt */
211211
212212
r20931r20932
226226
227227TIMER_DEVICE_CALLBACK_MEMBER(m92_state::m92_scanline_interrupt)
228228{
229   m92_state *state = machine().driver_data<m92_state>();
230229   int scanline = param;
231230
232231   /* raster interrupt */
233232   if (scanline == m_raster_irq_position)
234233   {
235234      machine().primary_screen->update_partial(scanline);
236      state->m_maincpu->set_input_line_and_vector(0, HOLD_LINE, M92_IRQ_2);
235      m_maincpu->set_input_line_and_vector(0, HOLD_LINE, M92_IRQ_2);
237236   }
238237
239238   /* VBLANK interrupt */
240239   else if (scanline == machine().primary_screen->visible_area().max_y + 1)
241240   {
242241      machine().primary_screen->update_partial(scanline);
243      state->m_maincpu->set_input_line_and_vector(0, HOLD_LINE, M92_IRQ_0);
242      m_maincpu->set_input_line_and_vector(0, HOLD_LINE, M92_IRQ_0);
244243   }
245244}
246245
r20931r20932
908907
909908/***************************************************************************/
910909
911void m92_sprite_interrupt(running_machine &machine)
910void m92_state::m92_sprite_interrupt()
912911{
913   m92_state *state = machine.driver_data<m92_state>();
914
915   state->m_maincpu->set_input_line_and_vector(0, HOLD_LINE, M92_IRQ_1);
912   m_maincpu->set_input_line_and_vector(0, HOLD_LINE, M92_IRQ_1);
916913}
917914
918915static MACHINE_CONFIG_START( m92, m92_state )
trunk/src/mame/drivers/madalien.c
r20931r20932
2323}
2424
2525
26INLINE UINT8 shift_common(running_machine &machine, UINT8 hi, UINT8 lo)
26inline UINT8 madalien_state::shift_common(UINT8 hi, UINT8 lo)
2727{
28   const UINT8 *table = machine.root_device().memregion("user2")->base();
28   const UINT8 *table = machine().root_device().memregion("user2")->base();
2929
3030   return table[((hi & 0x07) << 8) | lo];
3131}
3232
3333READ8_MEMBER(madalien_state::shift_r)
3434{
35   return shift_common(machine(), *m_shift_hi, *m_shift_lo);
35   return shift_common(*m_shift_hi, *m_shift_lo);
3636}
3737
3838READ8_MEMBER(madalien_state::shift_rev_r)
r20931r20932
4040   UINT8 hi = *m_shift_hi ^ 0x07;
4141   UINT8 lo = BITSWAP8(*m_shift_lo,0,1,2,3,4,5,6,7);
4242
43   UINT8 ret = shift_common(machine(), hi, lo);
43   UINT8 ret = shift_common(hi, lo);
4444
4545   return BITSWAP8(ret,7,0,1,2,3,4,5,6) & 0x7f;
4646}
trunk/src/mame/drivers/mcr.c
r20931r20932
27512751 *
27522752 *************************************/
27532753
2754static void mcr_init(running_machine &machine, int cpuboard, int vidboard, int ssioboard)
2754void mcr_state::mcr_init(int cpuboard, int vidboard, int ssioboard)
27552755{
27562756   mcr_cpu_board = cpuboard;
27572757   mcr_sprite_board = vidboard;
r20931r20932
27592759   mcr12_sprite_xoffs = 0;
27602760   mcr12_sprite_xoffs_flip = 0;
27612761
2762   state_save_register_global(machine, input_mux);
2763   state_save_register_global(machine, last_op4);
2762   state_save_register_global(machine(), input_mux);
2763   state_save_register_global(machine(), last_op4);
27642764
2765   midway_ssio_device *ssio = machine.device<midway_ssio_device>("ssio");
2765   midway_ssio_device *ssio = machine().device<midway_ssio_device>("ssio");
27662766   if (ssio != NULL)
27672767   {
2768      mcr_state *state = machine.driver_data<mcr_state>();
2769      ssio->set_custom_output(0, 0xff, write8_delegate(FUNC(mcr_state::mcr_control_port_w), state));
2768      ssio->set_custom_output(0, 0xff, write8_delegate(FUNC(mcr_state::mcr_control_port_w), this));
27702769   }
27712770}
27722771
27732772
27742773DRIVER_INIT_MEMBER(mcr_state,solarfox)
27752774{
2776   mcr_init(machine(), 90009, 91399, 90908);
2775   mcr_init(90009, 91399, 90908);
27772776   mcr12_sprite_xoffs = 16;
27782777
27792778   machine().device<midway_ssio_device>("ssio")->set_custom_input(0, 0x1c, read8_delegate(FUNC(mcr_state::solarfox_ip0_r),this));
r20931r20932
27832782
27842783DRIVER_INIT_MEMBER(mcr_state,kick)
27852784{
2786   mcr_init(machine(), 90009, 91399, 90908);
2785   mcr_init(90009, 91399, 90908);
27872786   mcr12_sprite_xoffs_flip = 16;
27882787
27892788   machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0xf0, read8_delegate(FUNC(mcr_state::kick_ip1_r),this));
r20931r20932
27922791
27932792DRIVER_INIT_MEMBER(mcr_state,dpoker)
27942793{
2795   mcr_init(machine(), 90009, 91399, 90908);
2794   mcr_init(90009, 91399, 90908);
27962795   mcr12_sprite_xoffs_flip = 16;
27972796
27982797   machine().device<midway_ssio_device>("ssio")->set_custom_input(0, 0x8e, read8_delegate(FUNC(mcr_state::dpoker_ip0_r),this));
r20931r20932
28202819
28212820DRIVER_INIT_MEMBER(mcr_state,mcr_90010)
28222821{
2823   mcr_init(machine(), 90010, 91399, 90913);
2822   mcr_init(90010, 91399, 90913);
28242823}
28252824
28262825
28272826DRIVER_INIT_MEMBER(mcr_state,wacko)
28282827{
2829   mcr_init(machine(), 90010, 91399, 90913);
2828   mcr_init(90010, 91399, 90913);
28302829
28312830   machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0xff, read8_delegate(FUNC(mcr_state::wacko_ip1_r),this));
28322831   machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xff, read8_delegate(FUNC(mcr_state::wacko_ip2_r),this));
r20931r20932
28362835
28372836DRIVER_INIT_MEMBER(mcr_state,twotiger)
28382837{
2839   mcr_init(machine(), 90010, 91399, 90913);
2838   mcr_init(90010, 91399, 90913);
28402839
28412840   machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr_state::twotiger_op4_w),this));
28422841   machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xe800, 0xefff, 0, 0x1000, read8_delegate(FUNC(mcr_state::twotiger_videoram_r),this), write8_delegate(FUNC(mcr_state::twotiger_videoram_w),this));
r20931r20932
28452844
28462845DRIVER_INIT_MEMBER(mcr_state,kroozr)
28472846{
2848   mcr_init(machine(), 90010, 91399, 91483);
2847   mcr_init(90010, 91399, 91483);
28492848
28502849   machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0x47, read8_delegate(FUNC(mcr_state::kroozr_ip1_r),this));
28512850   machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0x34, write8_delegate(FUNC(mcr_state::kroozr_op4_w),this));
r20931r20932
28542853
28552854DRIVER_INIT_MEMBER(mcr_state,journey)
28562855{
2857   mcr_init(machine(), 91475, 91464, 90913);
2856   mcr_init(91475, 91464, 90913);
28582857
28592858   machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0x01, write8_delegate(FUNC(mcr_state::journey_op4_w),this));
28602859}
r20931r20932
28622861
28632862DRIVER_INIT_MEMBER(mcr_state,mcr_91490)
28642863{
2865   mcr_init(machine(), 91490, 91464, 90913);
2864   mcr_init(91490, 91464, 90913);
28662865}
28672866
28682867
28692868DRIVER_INIT_MEMBER(mcr_state,dotrone)
28702869{
2871   mcr_init(machine(), 91490, 91464, 91657);
2870   mcr_init(91490, 91464, 91657);
28722871
28732872   machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr_state::dotron_op4_w),this));
28742873}
r20931r20932
28762875
28772876DRIVER_INIT_MEMBER(mcr_state,nflfoot)
28782877{
2879   mcr_init(machine(), 91490, 91464, 91657);
2878   mcr_init(91490, 91464, 91657);
28802879
28812880   machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0x80, read8_delegate(FUNC(mcr_state::nflfoot_ip2_r),this));
28822881   machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr_state::nflfoot_op4_w),this));
r20931r20932
28952894
28962895DRIVER_INIT_MEMBER(mcr_state,demoderb)
28972896{
2898   mcr_init(machine(), 91490, 91464, 90913);
2897   mcr_init(91490, 91464, 90913);
28992898
29002899   machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0xfc, read8_delegate(FUNC(mcr_state::demoderb_ip1_r),this));
29012900   machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xfc, read8_delegate(FUNC(mcr_state::demoderb_ip2_r),this));
trunk/src/mame/drivers/macrossp.c
r20931r20932
349349   return soundlatch_word_r(space, offset, mem_mask);
350350}
351351
352static void update_colors( running_machine &machine )
352void macrossp_state::update_colors(  )
353353{
354   macrossp_state *state = machine.driver_data<macrossp_state>();
355354   int i, r, g, b;
356355
357356   for (i = 0; i < 0x1000; i++)
358357   {
359      b = ((state->m_paletteram[i] & 0x0000ff00) >>  8);
360      g = ((state->m_paletteram[i] & 0x00ff0000) >> 16);
361      r = ((state->m_paletteram[i] & 0xff000000) >> 24);
358      b = ((m_paletteram[i] & 0x0000ff00) >>  8);
359      g = ((m_paletteram[i] & 0x00ff0000) >> 16);
360      r = ((m_paletteram[i] & 0xff000000) >> 24);
362361
363      if (state->m_fade_effect > b)
362      if (m_fade_effect > b)
364363         b = 0;
365364      else
366         b -= state->m_fade_effect;
365         b -= m_fade_effect;
367366
368      if (state->m_fade_effect > g)
367      if (m_fade_effect > g)
369368         g = 0;
370369      else
371         g -= state->m_fade_effect;
370         g -= m_fade_effect;
372371
373      if (state->m_fade_effect > r)
372      if (m_fade_effect > r)
374373         r = 0;
375374      else
376         r -= state->m_fade_effect;
375         r -= m_fade_effect;
377376
378      palette_set_color(machine, i, MAKE_RGB(r, g, b));
377      palette_set_color(machine(), i, MAKE_RGB(r, g, b));
379378   }
380379}
381380
r20931r20932
387386   if (m_old_fade != m_fade_effect)
388387   {
389388      m_old_fade = m_fade_effect;
390      update_colors(machine());
389      update_colors();
391390   }
392391}
393392
trunk/src/mame/drivers/metro.c
r20931r20932
558558   update_irq_state();
559559}
560560
561INLINE int blt_read( const UINT8 *ROM, const int offs )
561inline int metro_state::blt_read( const UINT8 *ROM, const int offs )
562562{
563563   return ROM[offs];
564564}
r20931r20932
62636263
62646264***************************************************************************/
62656265
6266static void metro_common( running_machine &machine )
6266void metro_state::metro_common(  )
62676267{
6268   metro_state *state = machine.driver_data<metro_state>();
62696268
6270   memset(state->m_requested_int, 0, ARRAY_LENGTH(state->m_requested_int));
6271   state->m_vblank_bit = 0;
6272   state->m_blitter_bit = 2;
6273   state->m_irq_line = 2;
6269   memset(m_requested_int, 0, ARRAY_LENGTH(m_requested_int));
6270   m_vblank_bit = 0;
6271   m_blitter_bit = 2;
6272   m_irq_line = 2;
62746273
6275   *state->m_irq_enable = 0;
6274   *m_irq_enable = 0;
62766275}
62776276
62786277
r20931r20932
62806279{
62816280   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
62826281
6283   metro_common(machine());
6282   metro_common();
62846283
62856284   m_porta = 0x00;
62866285   m_portb = 0x00;
r20931r20932
63076306{
63086307   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
63096308
6310   metro_common(machine());
6309   metro_common();
63116310
63126311   m_porta = 0x00;
63136312   m_portb = 0x00;
r20931r20932
63336332      src   +=  2;
63346333   }
63356334
6336   metro_common(machine());
6335   metro_common();
63376336   m_irq_line = 1;
63386337}
63396338
r20931r20932
63606359
63616360DRIVER_INIT_MEMBER(metro_state,blzntrnd)
63626361{
6363   metro_common(machine());
6362   metro_common();
63646363   m_irq_line = 1;
63656364}
63666365
63676366DRIVER_INIT_MEMBER(metro_state,mouja)
63686367{
6369   metro_common(machine());
6368   metro_common();
63706369   m_irq_line = -1;    /* split interrupt handlers */
63716370   m_vblank_bit = 1;
63726371   m_mouja_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(metro_state::mouja_irq_callback),this));
r20931r20932
63746373
63756374DRIVER_INIT_MEMBER(metro_state,gakusai)
63766375{
6377   metro_common(machine());
6376   metro_common();
63786377   m_irq_line = -1;
63796378   m_vblank_bit = 1;
63806379   m_blitter_bit = 3;
r20931r20932
63826381
63836382DRIVER_INIT_MEMBER(metro_state,puzzlet)
63846383{
6385   metro_common(machine());
6384   metro_common();
63866385   m_irq_line = 0;
63876386   m_vblank_bit = 1;
63886387   m_blitter_bit = 0;
trunk/src/mame/drivers/megasys1.c
r20931r20932
36083608ROM_END
36093609
36103610
3611static void rodlandj_gfx_unmangle(running_machine &machine, const char *region)
3611void megasys1_state::rodlandj_gfx_unmangle(const char *region)
36123612{
3613   UINT8 *rom = machine.root_device().memregion(region)->base();
3614   int size = machine.root_device().memregion(region)->bytes();
3613   UINT8 *rom = machine().root_device().memregion(region)->base();
3614   int size = machine().root_device().memregion(region)->bytes();
36153615   UINT8 *buffer;
36163616   int i;
36173617
r20931r20932
36223622            | ((rom[i] & 0x48) << 1)
36233623            | ((rom[i] & 0x10) << 2);
36243624
3625   buffer = auto_alloc_array(machine, UINT8, size);
3625   buffer = auto_alloc_array(machine(), UINT8, size);
36263626
36273627   memcpy(buffer,rom,size);
36283628
r20931r20932
36373637      rom[i] = buffer[a];
36383638   }
36393639
3640   auto_free(machine, buffer);
3640   auto_free(machine(), buffer);
36413641}
36423642
3643static void jitsupro_gfx_unmangle(running_machine &machine, const char *region)
3643void megasys1_state::jitsupro_gfx_unmangle(const char *region)
36443644{
3645   UINT8 *rom = machine.root_device().memregion(region)->base();
3646   int size = machine.root_device().memregion(region)->bytes();
3645   UINT8 *rom = machine().root_device().memregion(region)->base();
3646   int size = machine().root_device().memregion(region)->bytes();
36473647   UINT8 *buffer;
36483648   int i;
36493649
r20931r20932
36513651   for (i = 0;i < size;i++)
36523652      rom[i] =   BITSWAP8(rom[i],0x4,0x3,0x5,0x7,0x6,0x2,0x1,0x0);
36533653
3654   buffer = auto_alloc_array(machine, UINT8, size);
3654   buffer = auto_alloc_array(machine(), UINT8, size);
36553655
36563656   memcpy(buffer,rom,size);
36573657
r20931r20932
36643664      rom[i] = buffer[a];
36653665   }
36663666
3667   auto_free(machine, buffer);
3667   auto_free(machine(), buffer);
36683668}
36693669
3670static void stdragona_gfx_unmangle(running_machine &machine, const char *region)
3670void megasys1_state::stdragona_gfx_unmangle(const char *region)
36713671{
3672   UINT8 *rom = machine.root_device().memregion(region)->base();
3673   int size = machine.root_device().memregion(region)->bytes();
3672   UINT8 *rom = machine().root_device().memregion(region)->base();
3673   int size = machine().root_device().memregion(region)->bytes();
36743674   UINT8 *buffer;
36753675   int i;
36763676
r20931r20932
36783678   for (i = 0;i < size;i++)
36793679      rom[i] =   BITSWAP8(rom[i],3,7,5,6,4,2,1,0);
36803680
3681   buffer = auto_alloc_array(machine, UINT8, size);
3681   buffer = auto_alloc_array(machine(), UINT8, size);
36823682
36833683   memcpy(buffer,rom,size);
36843684
r20931r20932
36913691      rom[i] = buffer[a];
36923692   }
36933693
3694   auto_free(machine, buffer);
3694   auto_free(machine(), buffer);
36953695}
36963696
36973697/*************************************
r20931r20932
39273927
39283928   astyanax_rom_decode(machine(), "maincpu");      // Code
39293929
3930   jitsupro_gfx_unmangle(machine(), "gfx1");   // Gfx
3931   jitsupro_gfx_unmangle(machine(), "gfx4");
3930   jitsupro_gfx_unmangle("gfx1");   // Gfx
3931   jitsupro_gfx_unmangle("gfx4");
39323932   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x00000, 0x3ffff, read16_delegate(FUNC(megasys1_state::megasys1A_mcu_hs_r),this));
39333933   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x20000, 0x20009, write16_delegate(FUNC(megasys1_state::megasys1A_mcu_hs_w),this));
39343934
r20931r20932
39543954
39553955DRIVER_INIT_MEMBER(megasys1_state,rodlandj)
39563956{
3957   rodlandj_gfx_unmangle(machine(), "gfx1");
3958   rodlandj_gfx_unmangle(machine(), "gfx4");
3957   rodlandj_gfx_unmangle("gfx1");
3958   rodlandj_gfx_unmangle("gfx4");
39593959
39603960   astyanax_rom_decode(machine(), "maincpu");
39613961}
r20931r20932
40254025{
40264026   phantasm_rom_decode(machine(), "maincpu");
40274027
4028   stdragona_gfx_unmangle(machine(), "gfx1");
4029   stdragona_gfx_unmangle(machine(), "gfx4");
4028   stdragona_gfx_unmangle("gfx1");
4029   stdragona_gfx_unmangle("gfx4");
40304030
40314031   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x00000, 0x3ffff, read16_delegate(FUNC(megasys1_state::stdragon_mcu_hs_r),this));
40324032   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x23ff0, 0x23ff9, write16_delegate(FUNC(megasys1_state::stdragon_mcu_hs_w),this));
trunk/src/mame/drivers/mitchell.c
r20931r20932
20802080 *
20812081 *************************************/
20822082
2083static void bootleg_decode( running_machine &machine )
2083void mitchell_state::bootleg_decode(  )
20842084{
2085   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
2086   space.set_decrypted_region(0x0000, 0x7fff, machine.root_device().memregion("maincpu")->base() + 0x50000);
2087   machine.root_device().membank("bank1")->configure_decrypted_entries(0, 16, machine.root_device().memregion("maincpu")->base() + 0x60000, 0x4000);
2085   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
2086   space.set_decrypted_region(0x0000, 0x7fff, machine().root_device().memregion("maincpu")->base() + 0x50000);
2087   machine().root_device().membank("bank1")->configure_decrypted_entries(0, 16, machine().root_device().memregion("maincpu")->base() + 0x60000, 0x4000);
20882088}
20892089
20902090
2091static void configure_banks( running_machine &machine )
2091void mitchell_state::configure_banks(  )
20922092{
2093   machine.root_device().membank("bank1")->configure_entries(0, 16, machine.root_device().memregion("maincpu")->base() + 0x10000, 0x4000);
2093   machine().root_device().membank("bank1")->configure_entries(0, 16, machine().root_device().memregion("maincpu")->base() + 0x10000, 0x4000);
20942094}
20952095
20962096
r20931r20932
20982098{
20992099   m_input_type = 0;
21002100   mgakuen2_decode(machine());
2101   configure_banks(machine());
2101   configure_banks();
21022102}
21032103DRIVER_INIT_MEMBER(mitchell_state,pang)
21042104{
21052105   m_input_type = 0;
21062106   pang_decode(machine());
2107   configure_banks(machine());
2107   configure_banks();
21082108}
21092109DRIVER_INIT_MEMBER(mitchell_state,pangb)
21102110{
21112111   m_input_type = 0;
2112   bootleg_decode(machine());
2113   configure_banks(machine());
2112   bootleg_decode();
2113   configure_banks();
21142114   if (m_nvram != NULL)
21152115      m_nvram->set_base(&m_dummy_nvram, sizeof(m_dummy_nvram));   /* for pangba */
21162116}
r20931r20932
21182118{
21192119   m_input_type = 0;
21202120   cworld_decode(machine());
2121   configure_banks(machine());
2121   configure_banks();
21222122}
21232123DRIVER_INIT_MEMBER(mitchell_state,hatena)
21242124{
21252125   m_input_type = 0;
21262126   hatena_decode(machine());
2127   configure_banks(machine());
2127   configure_banks();
21282128}
21292129DRIVER_INIT_MEMBER(mitchell_state,spang)
21302130{
21312131   m_input_type = 3;
21322132   m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */
21332133   spang_decode(machine());
2134   configure_banks(machine());
2134   configure_banks();
21352135}
21362136
21372137DRIVER_INIT_MEMBER(mitchell_state,spangbl)
21382138{
21392139   m_input_type = 3;
21402140   m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */
2141   bootleg_decode(machine());
2142   configure_banks(machine());
2141   bootleg_decode();
2142   configure_banks();
21432143}
21442144
21452145DRIVER_INIT_MEMBER(mitchell_state,spangj)
r20931r20932
21472147   m_input_type = 3;
21482148   m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */
21492149   spangj_decode(machine());
2150   configure_banks(machine());
2150   configure_banks();
21512151}
21522152DRIVER_INIT_MEMBER(mitchell_state,sbbros)
21532153{
21542154   m_input_type = 3;
21552155   m_nvram->set_base(&memregion("maincpu")->base()[0xe000], 0x80); /* NVRAM */
21562156   sbbros_decode(machine());
2157   configure_banks(machine());
2157   configure_banks();
21582158}
21592159DRIVER_INIT_MEMBER(mitchell_state,qtono1)
21602160{
21612161   m_input_type = 0;
21622162   qtono1_decode(machine());
2163   configure_banks(machine());
2163   configure_banks();
21642164}
21652165DRIVER_INIT_MEMBER(mitchell_state,qsangoku)
21662166{
21672167   m_input_type = 0;
21682168   qsangoku_decode(machine());
2169   configure_banks(machine());
2169   configure_banks();
21702170}
21712171DRIVER_INIT_MEMBER(mitchell_state,mgakuen)
21722172{
21732173   m_input_type = 1;
2174   configure_banks(machine());
2174   configure_banks();
21752175   machine().device("maincpu")->memory().space(AS_IO).install_read_port(0x03, 0x03, "DSW0");
21762176   machine().device("maincpu")->memory().space(AS_IO).install_read_port(0x04, 0x04, "DSW1");
21772177}
r20931r20932
21792179{
21802180   m_input_type = 1;
21812181   mgakuen2_decode(machine());
2182   configure_banks(machine());
2182   configure_banks();
21832183}
21842184DRIVER_INIT_MEMBER(mitchell_state,pkladies)
21852185{
21862186   m_input_type = 1;
21872187   mgakuen2_decode(machine());
2188   configure_banks(machine());
2188   configure_banks();
21892189}
21902190DRIVER_INIT_MEMBER(mitchell_state,pkladiesbl)
21912191{
21922192   m_input_type = 1;
2193   bootleg_decode(machine());
2194   configure_banks(machine());
2193   bootleg_decode();
2194   configure_banks();
21952195}
21962196DRIVER_INIT_MEMBER(mitchell_state,marukin)
21972197{
21982198   m_input_type = 1;
21992199   marukin_decode(machine());
2200   configure_banks(machine());
2200   configure_banks();
22012201}
22022202DRIVER_INIT_MEMBER(mitchell_state,block)
22032203{
22042204   m_input_type = 2;
22052205   m_nvram->set_base(&memregion("maincpu")->base()[0xff80], 0x80); /* NVRAM */
22062206   block_decode(machine());
2207   configure_banks(machine());
2207   configure_banks();
22082208}
22092209DRIVER_INIT_MEMBER(mitchell_state,blockbl)
22102210{
22112211   m_input_type = 2;
22122212   m_nvram->set_base(&memregion("maincpu")->base()[0xff80], 0x80); /* NVRAM */
2213   bootleg_decode(machine());
2214   configure_banks(machine());
2213   bootleg_decode();
2214   configure_banks();
22152215}
22162216
22172217DRIVER_INIT_MEMBER(mitchell_state,mstworld)
r20931r20932
22572257   }
22582258   auto_free(machine(), source);
22592259
2260   bootleg_decode(machine());
2261   configure_banks(machine());
2260   bootleg_decode();
2261   configure_banks();
22622262}
22632263
22642264
trunk/src/mame/drivers/mystston.c
r20931r20932
3737 *
3838 *************************************/
3939
40void mystston_on_scanline_interrupt(running_machine &machine)
40void mystston_state::mystston_on_scanline_interrupt()
4141{
42   machine.device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
42   machine().device("maincpu")->execute().set_input_line(0, ASSERT_LINE);
4343}
4444
4545
trunk/src/mame/drivers/mw8080bw.c
r20931r20932
552552#define TORNBASE_CAB_TYPE_PORT_TAG      ("CAB")
553553
554554
555UINT8 tornbase_get_cabinet_type(running_machine &machine)
555UINT8 mw8080bw_state::tornbase_get_cabinet_type()
556556{
557   return machine.root_device().ioport(TORNBASE_CAB_TYPE_PORT_TAG)->read();
557   return machine().root_device().ioport(TORNBASE_CAB_TYPE_PORT_TAG)->read();
558558}
559559
560560
r20931r20932
568568{
569569   UINT32 ret;
570570
571   switch (tornbase_get_cabinet_type(machine()))
571   switch (tornbase_get_cabinet_type())
572572   {
573573   case TORNBASE_CAB_TYPE_UPRIGHT_OLD:
574574      ret = ioport(TORNBASE_L_HIT_PORT_TAG)->read();
r20931r20932
589589{
590590   UINT32 ret;
591591
592   switch (tornbase_get_cabinet_type(machine()))
592   switch (tornbase_get_cabinet_type())
593593   {
594594   case TORNBASE_CAB_TYPE_UPRIGHT_OLD:
595595   case TORNBASE_CAB_TYPE_UPRIGHT_NEW:
r20931r20932
21222122}
21232123
21242124#if 0
2125UINT8 spcenctr_get_trench_width( *running_machine &machine )
2125UINT8 mw8080bw_state::spcenctr_get_trench_width()
21262126{
2127   mw8080bw_state *state = machine.driver_data<mw8080bw_state>();
2128   return state->m_spcenctr_trench_width;
2127   return m_spcenctr_trench_width;
21292128}
21302129
21312130
2132UINT8 spcenctr_get_trench_center( *running_machine &machine )
2131UINT8 mw8080bw_state::spcenctr_get_trench_center()
21332132{
2134   mw8080bw_state *state = machine.driver_data<mw8080bw_state>();
2135   return state->m_spcenctr_trench_center;
2133   return m_spcenctr_trench_center;
21362134}
21372135
21382136
2139UINT8 spcenctr_get_trench_slope( *running_machine &machine, UINT8 addr )
2137UINT8 mw8080bw_state::spcenctr_get_trench_slope(UINT8 addr )
21402138{
2141   mw8080bw_state *state = machine.driver_data<mw8080bw_state>();
2142   return state->m_spcenctr_trench_slope[addr & 0x0f];
2139   return m_spcenctr_trench_slope[addr & 0x0f];
21432140}
21442141#endif
21452142
r20931r20932
25192516   /* upright PCB : switches visible
25202517      cocktail PCB: HI */
25212518
2522   if (invaders_is_cabinet_cocktail(machine()))
2519   if (invaders_is_cabinet_cocktail())
25232520      ret = 0x03;
25242521   else
25252522      ret = ioport(INVADERS_SW6_SW7_PORT_TAG)->read();
r20931r20932
25352532   /* upright PCB : switch visible
25362533      cocktail PCB: HI */
25372534
2538   if (invaders_is_cabinet_cocktail(machine()))
2535   if (invaders_is_cabinet_cocktail())
25392536      ret = 0x01;
25402537   else
25412538      ret = ioport(INVADERS_SW5_PORT_TAG)->read();
r20931r20932
25512548   /* upright PCB : P1 controls
25522549      cocktail PCB: HI */
25532550
2554   if (invaders_is_cabinet_cocktail(machine()))
2551   if (invaders_is_cabinet_cocktail())
25552552      ret = 0x07;
25562553   else
25572554      ret = ioport(INVADERS_P1_CONTROL_PORT_TAG)->read();
r20931r20932
25732570   /* upright PCB : P1 controls
25742571      cocktail PCB: P2 controls */
25752572
2576   if (invaders_is_cabinet_cocktail(machine()))
2573   if (invaders_is_cabinet_cocktail())
25772574      ret = ioport(INVADERS_P2_CONTROL_PORT_TAG)->read();
25782575   else
25792576      ret = ioport(INVADERS_P1_CONTROL_PORT_TAG)->read();
r20931r20932
25822579}
25832580
25842581
2585int invaders_is_cabinet_cocktail(running_machine &machine)
2582int mw8080bw_state::invaders_is_cabinet_cocktail()
25862583{
2587   return machine.root_device().ioport(INVADERS_CAB_TYPE_PORT_TAG)->read();
2584   return machine().root_device().ioport(INVADERS_CAB_TYPE_PORT_TAG)->read();
25882585}
25892586
25902587
r20931r20932
27882785
27892786
27902787#ifdef UNUSED_FUNCTION
2791static UINT32 invad2ct_coin_input_r(void *param)
2788UINT32 mw8080bw_state::invad2ct_coin_input_r(void *param)
27922789{
2793   UINT32 ret = machine.root_device().ioport(INVAD2CT_COIN_INPUT_PORT_TAG)->read();
2790   UINT32 ret = machine().root_device().ioport(INVAD2CT_COIN_INPUT_PORT_TAG)->read();
27942791
27952792   coin_counter_w(machine, 0, !ret);
27962793
trunk/src/mame/drivers/ms32.c
r20931r20932
21912191ROM_END
21922192
21932193
2194static void configure_banks(running_machine &machine)
2194void ms32_state::configure_banks()
21952195{
2196   ms32_state *state = machine.driver_data<ms32_state>();
2197   state_save_register_global(machine, state->m_to_main);
2198   state->membank("bank4")->configure_entries(0, 16, state->memregion("audiocpu")->base() + 0x14000, 0x4000);
2199   state->membank("bank5")->configure_entries(0, 16, state->memregion("audiocpu")->base() + 0x14000, 0x4000);
2196   state_save_register_global(machine(), m_to_main);
2197   membank("bank4")->configure_entries(0, 16, memregion("audiocpu")->base() + 0x14000, 0x4000);
2198   membank("bank5")->configure_entries(0, 16, memregion("audiocpu")->base() + 0x14000, 0x4000);
22002199}
22012200
22022201DRIVER_INIT_MEMBER(ms32_state,ms32_common)
22032202{
22042203   m_nvram_8 = auto_alloc_array(machine(), UINT8, 0x2000);
2205   configure_banks(machine());
2204   configure_banks();
22062205}
22072206
22082207/* SS91022-10: desertwr, gratiaa, tp2m32, gametngk */
trunk/src/mame/drivers/mcr3.c
r20931r20932
15231523 *
15241524 *************************************/
15251525
1526static void mcr_common_init(running_machine &machine)
1526void mcr3_state::mcr_common_init()
15271527{
1528   mcr3_state *state = machine.driver_data<mcr3_state>();
1529
1530   state_save_register_global(machine, state->m_input_mux);
1531   state_save_register_global(machine, state->m_latched_input);
1532   state_save_register_global(machine, state->m_last_op4);
1528   state_save_register_global(machine(), m_input_mux);
1529   state_save_register_global(machine(), m_latched_input);
1530   state_save_register_global(machine(), m_last_op4);
15331531}
15341532
15351533
15361534DRIVER_INIT_MEMBER(mcr3_state,demoderm)
15371535{
1538   mcr_common_init(machine());
1536   mcr_common_init();
15391537   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x01, 0x01, read8_delegate(FUNC(mcr3_state::demoderm_ip1_r),this));
15401538   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x02, 0x02, read8_delegate(FUNC(mcr3_state::demoderm_ip2_r),this));
15411539   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::demoderm_op6_w),this));
r20931r20932
15441542
15451543DRIVER_INIT_MEMBER(mcr3_state,sarge)
15461544{
1547   mcr_common_init(machine());
1545   mcr_common_init();
15481546   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(midway_turbo_chip_squeak_device::write),m_turbo_chip_squeak.target()));
15491547}
15501548
15511549
15521550DRIVER_INIT_MEMBER(mcr3_state,maxrpm)
15531551{
1554   mcr_common_init(machine());
1552   mcr_common_init();
15551553   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x01, 0x01, read8_delegate(FUNC(mcr3_state::maxrpm_ip1_r),this));
15561554   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x02, 0x02, read8_delegate(FUNC(mcr3_state::maxrpm_ip2_r),this));
15571555   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x05, 0x05, write8_delegate(FUNC(mcr3_state::maxrpm_op5_w),this));
r20931r20932
15671565
15681566DRIVER_INIT_MEMBER(mcr3_state,rampage)
15691567{
1570   mcr_common_init(machine());
1568   mcr_common_init();
15711569   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x04, 0x04, read8_delegate(FUNC(mcr3_state::rampage_ip4_r),this));
15721570   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::rampage_op6_w),this));
15731571}
r20931r20932
15751573
15761574DRIVER_INIT_MEMBER(mcr3_state,powerdrv)
15771575{
1578   mcr_common_init(machine());
1576   mcr_common_init();
15791577   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x02, 0x02, read8_delegate(FUNC(mcr3_state::powerdrv_ip2_r),this));
15801578   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x05, 0x05, write8_delegate(FUNC(mcr3_state::powerdrv_op5_w),this));
15811579   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::powerdrv_op6_w),this));
r20931r20932
15841582
15851583DRIVER_INIT_MEMBER(mcr3_state,stargrds)
15861584{
1587   mcr_common_init(machine());
1585   mcr_common_init();
15881586   machine().device("maincpu")->memory().space(AS_IO).install_read_handler(0x00, 0x00, read8_delegate(FUNC(mcr3_state::stargrds_ip0_r),this));
15891587   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x05, 0x05, write8_delegate(FUNC(mcr3_state::stargrds_op5_w),this));
15901588   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0x06, 0x06, write8_delegate(FUNC(mcr3_state::stargrds_op6_w),this));
r20931r20932
15931591
15941592DRIVER_INIT_MEMBER(mcr3_state,spyhunt)
15951593{
1596   mcr_common_init(machine());
1594   mcr_common_init();
15971595   machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0x60, read8_delegate(FUNC(mcr3_state::spyhunt_ip1_r),this));
15981596   machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xff, read8_delegate(FUNC(mcr3_state::spyhunt_ip2_r),this));
15991597   machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr3_state::spyhunt_op4_w),this));
r20931r20932
16051603
16061604DRIVER_INIT_MEMBER(mcr3_state,crater)
16071605{
1608   mcr_common_init(machine());
1606   mcr_common_init();
16091607
16101608   m_spyhunt_sprite_color_mask = 0x03;
16111609   m_spyhunt_scroll_offset = 96;
r20931r20932
16141612
16151613DRIVER_INIT_MEMBER(mcr3_state,turbotag)
16161614{
1617   mcr_common_init(machine());
1615   mcr_common_init();
16181616   machine().device<midway_ssio_device>("ssio")->set_custom_input(1, 0x60, read8_delegate(FUNC(mcr3_state::spyhunt_ip1_r),this));
16191617   machine().device<midway_ssio_device>("ssio")->set_custom_input(2, 0xff, read8_delegate(FUNC(mcr3_state::turbotag_ip2_r),this));
16201618   machine().device<midway_ssio_device>("ssio")->set_custom_output(4, 0xff, write8_delegate(FUNC(mcr3_state::spyhunt_op4_w),this));
trunk/src/mame/drivers/maygay1b.c
r20931r20932
9999 *
100100 *************************************/
101101
102static void update_outputs(i8279_state *chip, UINT16 which)
102void maygay1b_state::update_outputs(i8279_state *chip, UINT16 which)
103103{
104104   static const UINT8 ls48_map[16] =
105105      { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67,0x58,0x4c,0x62,0x69,0x78,0x00 };
r20931r20932
456456// called if board is reset ///////////////////////////////////////////////
457457///////////////////////////////////////////////////////////////////////////
458458
459static void m1_stepper_reset(running_machine &machine)
459void maygay1b_state::m1_stepper_reset()
460460{
461   maygay1b_state *state = machine.driver_data<maygay1b_state>();
462461   int pattern = 0,i;
463462   for ( i = 0; i < 6; i++)
464463   {
465464      stepper_reset_position(i);
466465      if ( stepper_optic_state(i) ) pattern |= 1<<i;
467466   }
468   state->m_optic_pattern = pattern;
467   m_optic_pattern = pattern;
469468}
470469
471470void maygay1b_state::machine_reset()
472471{
473472   m_vfd->reset(); // reset display1
474473   m_duart68681 = machine().device( "duart68681" );
475   m1_stepper_reset(machine());
474   m1_stepper_reset();
476475}
477476
478477///////////////////////////////////////////////////////////////////////////
trunk/src/mame/drivers/mcr68.c
r20931r20932
15341534 *
15351535 *************************************/
15361536
1537static void mcr68_common_init(running_machine &machine, int clip, int xoffset)
1537void mcr68_state::mcr68_common_init(int clip, int xoffset)
15381538{
1539   mcr68_state *state = machine.driver_data<mcr68_state>();
15401539
1541   state->m_sprite_clip = clip;
1542   state->m_sprite_xoffset = xoffset;
1540   m_sprite_clip = clip;
1541   m_sprite_xoffset = xoffset;
15431542
1544   state_save_register_global(machine, state->m_control_word);
1543   state_save_register_global(machine(), m_control_word);
15451544}
15461545
15471546
15481547DRIVER_INIT_MEMBER(mcr68_state,zwackery)
15491548{
1550   mcr68_common_init(machine(), 0, 0);
1549   mcr68_common_init(0, 0);
15511550
15521551   /* Zwackery doesn't care too much about this value; currently taken from Blasted */
15531552   m_timing_factor = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10) * (256 + 16);
r20931r20932
15561555
15571556DRIVER_INIT_MEMBER(mcr68_state,xenophob)
15581557{
1559   mcr68_common_init(machine(), 0, -4);
1558   mcr68_common_init(0, -4);
15601559
15611560   /* Xenophobe doesn't care too much about this value; currently taken from Blasted */
15621561   m_timing_factor = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10) * (256 + 16);
r20931r20932
15681567
15691568DRIVER_INIT_MEMBER(mcr68_state,spyhunt2)
15701569{
1571   mcr68_common_init(machine(), 0, -6);
1570   mcr68_common_init(0, -6);
15721571
15731572   /* Spy Hunter II doesn't care too much about this value; currently taken from Blasted */
15741573   m_timing_factor = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10) * (256 + 16);
r20931r20932
15821581
15831582DRIVER_INIT_MEMBER(mcr68_state,blasted)
15841583{
1585   mcr68_common_init(machine(), 0, 0);
1584   mcr68_common_init(0, 0);
15861585
15871586   /* Blasted checks the timing of VBLANK relative to the 493 interrupt */
15881587   /* VBLANK is required to come within 220-256 E clocks (i.e., 2200-2560 CPU clocks) */
r20931r20932
15981597
15991598DRIVER_INIT_MEMBER(mcr68_state,intlaser)
16001599{
1601   mcr68_common_init(machine(), 0, 0);
1600   mcr68_common_init(0, 0);
16021601
16031602   /* Copied from Blasted */
16041603   m_timing_factor = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10) * (256 + 16);
r20931r20932
16121611
16131612DRIVER_INIT_MEMBER(mcr68_state,archrivl)
16141613{
1615   mcr68_common_init(machine(), 16, 0);
1614   mcr68_common_init(16, 0);
16161615
16171616   /* Arch Rivals doesn't care too much about this value; currently taken from Blasted */
16181617   m_timing_factor = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10) * (256 + 16);
r20931r20932
16301629
16311630DRIVER_INIT_MEMBER(mcr68_state,pigskin)
16321631{
1633   mcr68_common_init(machine(), 16, 0);
1632   mcr68_common_init(16, 0);
16341633
16351634   /* Pigskin doesn't care too much about this value; currently taken from Tri-Sports */
16361635   m_timing_factor = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10) * 115;
r20931r20932
16411640
16421641DRIVER_INIT_MEMBER(mcr68_state,trisport)
16431642{
1644   mcr68_common_init(machine(), 0, 0);
1643   mcr68_common_init(0, 0);
16451644
16461645   /* Tri-Sports checks the timing of VBLANK relative to the 493 interrupt */
16471646   /* VBLANK is required to come within 87-119 E clocks (i.e., 870-1190 CPU clocks) */
trunk/src/mame/drivers/m72.c
r20931r20932
412412***************************************************************************/
413413
414414#if 0
415static int find_sample(int num)
415int m72_state::find_sample(int num)
416416{
417   UINT8 *rom = machine.root_device().memregion("samples")->base();
418   int len = machine.root_device().memregion("samples")->bytes();
417   UINT8 *rom = machine().root_device().memregion("samples")->base();
418   int len = machine().root_device().memregion("samples")->bytes();
419419   int addr = 0;
420420
421421   while (num--)
r20931r20932
683683
684684
685685
686static void copy_le(UINT16 *dest, const UINT8 *src, UINT8 bytes)
686void m72_state::copy_le(UINT16 *dest, const UINT8 *src, UINT8 bytes)
687687{
688688   int i;
689689
r20931r20932
708708      copy_le(&m_protection_ram[0x0fe0],m_protection_crc,CRC_LEN);
709709}
710710
711static void install_protection_handler(running_machine &machine, const UINT8 *code,const UINT8 *crc)
711void m72_state::install_protection_handler(const UINT8 *code,const UINT8 *crc)
712712{
713   m72_state *state = machine.driver_data<m72_state>();
714   state->m_protection_ram = auto_alloc_array(machine, UINT16, 0x1000/2);
715   state->m_protection_code = code;
716   state->m_protection_crc =  crc;
717   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xb0000, 0xb0fff, "bank1");
718   machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xb0ffa, 0xb0ffb, read16_delegate(FUNC(m72_state::protection_r),state));
719   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xb0000, 0xb0fff, write16_delegate(FUNC(m72_state::protection_w),state));
720   state->membank("bank1")->set_base(state->m_protection_ram);
713   m_protection_ram = auto_alloc_array(machine(), UINT16, 0x1000/2);
714   m_protection_code = code;
715   m_protection_crc =  crc;
716   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xb0000, 0xb0fff, "bank1");
717   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xb0ffa, 0xb0ffb, read16_delegate(FUNC(m72_state::protection_r),this));
718   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xb0000, 0xb0fff, write16_delegate(FUNC(m72_state::protection_w),this));
719   membank("bank1")->set_base(m_protection_ram);
721720}
722721
723722DRIVER_INIT_MEMBER(m72_state,bchopper)
724723{
725   install_protection_handler(machine(), bchopper_code,bchopper_crc);
724   install_protection_handler(bchopper_code,bchopper_crc);
726725   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::bchopper_sample_trigger_w),this));
727726}
728727
729728DRIVER_INIT_MEMBER(m72_state,mrheli)
730729{
731   install_protection_handler(machine(), bchopper_code,mrheli_crc);
730   install_protection_handler(bchopper_code,mrheli_crc);
732731   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::bchopper_sample_trigger_w),this));
733732}
734733
735734DRIVER_INIT_MEMBER(m72_state,nspirit)
736735{
737   install_protection_handler(machine(), nspirit_code,nspirit_crc);
736   install_protection_handler(nspirit_code,nspirit_crc);
738737   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::nspirit_sample_trigger_w),this));
739738}
740739
741740DRIVER_INIT_MEMBER(m72_state,imgfight)
742741{
743   install_protection_handler(machine(), imgfight_code,imgfightj_crc);
742   install_protection_handler(imgfight_code,imgfightj_crc);
744743   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::imgfight_sample_trigger_w),this));
745744}
746745
747746DRIVER_INIT_MEMBER(m72_state,loht)
748747{
749   install_protection_handler(machine(), loht_code,loht_crc);
748   install_protection_handler(loht_code,loht_crc);
750749
751750   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::loht_sample_trigger_w),this));
752751
r20931r20932
756755
757756DRIVER_INIT_MEMBER(m72_state,xmultiplm72)
758757{
759   install_protection_handler(machine(), xmultiplm72_code,xmultiplm72_crc);
758   install_protection_handler(xmultiplm72_code,xmultiplm72_crc);
760759   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::xmultiplm72_sample_trigger_w),this));
761760}
762761
763762DRIVER_INIT_MEMBER(m72_state,dbreedm72)
764763{
765   install_protection_handler(machine(), dbreedm72_code,dbreedm72_crc);
764   install_protection_handler(dbreedm72_code,dbreedm72_crc);
766765   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::dbreedm72_sample_trigger_w),this));
767766}
768767
769768DRIVER_INIT_MEMBER(m72_state,airduel)
770769{
771   install_protection_handler(machine(), airduel_code,airduel_crc);
770   install_protection_handler(airduel_code,airduel_crc);
772771   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::airduel_sample_trigger_w),this));
773772}
774773
775774DRIVER_INIT_MEMBER(m72_state,dkgenm72)
776775{
777   install_protection_handler(machine(), dkgenm72_code,dkgenm72_crc);
776   install_protection_handler(dkgenm72_code,dkgenm72_crc);
778777   machine().device("maincpu")->memory().space(AS_IO).install_write_handler(0xc0, 0xc1, write16_delegate(FUNC(m72_state::dkgenm72_sample_trigger_w),this));
779778}
780779
trunk/src/mame/audio/mw8080bw.c
r20931r20932
337337
338338   /* if (data & 0x10)  enable CHEER sound */
339339
340   if (tornbase_get_cabinet_type(machine()) == TORNBASE_CAB_TYPE_UPRIGHT_OLD)
340   if (tornbase_get_cabinet_type() == TORNBASE_CAB_TYPE_UPRIGHT_OLD)
341341   {
342342      /* if (data & 0x20)  enable WHISTLE sound */
343343
r20931r20932
41954195   discrete_sound_w(m_discrete, space, INVADERS_NODE(INVADERS_SAUCER_HIT_EN, 1), data & 0x10);
41964196
41974197   /* the flip screen line is only connected on the cocktail PCB */
4198   if (invaders_is_cabinet_cocktail(machine()))
4198   if (invaders_is_cabinet_cocktail())
41994199   {
42004200      m_flip_screen = (data >> 5) & 0x01;
42014201   }
trunk/src/mame/machine/mexico86.c
r20931r20932
4141
4242***************************************************************************/
4343
44static void mcu_simulate( running_machine &machine )
44void mexico86_state::mcu_simulate(  )
4545{
46   mexico86_state *state = machine.driver_data<mexico86_state>();
4746
48   if (!state->m_mcu_initialised)
47   if (!m_mcu_initialised)
4948   {
50      if (state->m_protection_ram[0x01] == 0x00)
49      if (m_protection_ram[0x01] == 0x00)
5150      {
5251         logerror("initialising MCU\n");
53         state->m_protection_ram[0x04] = 0xfc;   // coin inputs
54         state->m_protection_ram[0x02] = 0xff;   // player 1
55         state->m_protection_ram[0x03] = 0xff;   // player 2
56         state->m_protection_ram[0x1b] = 0xff;   // active player
57         state->m_protection_ram[0x06] = 0xff;   // must be FF otherwise PS4 ERROR
58         state->m_protection_ram[0x07] = 0x03;   // must be 03 otherwise PS4 ERROR
59         state->m_protection_ram[0x00] = 0x00;
60         state->m_mcu_initialised = 1;
52         m_protection_ram[0x04] = 0xfc;   // coin inputs
53         m_protection_ram[0x02] = 0xff;   // player 1
54         m_protection_ram[0x03] = 0xff;   // player 2
55         m_protection_ram[0x1b] = 0xff;   // active player
56         m_protection_ram[0x06] = 0xff;   // must be FF otherwise PS4 ERROR
57         m_protection_ram[0x07] = 0x03;   // must be 03 otherwise PS4 ERROR
58         m_protection_ram[0x00] = 0x00;
59         m_mcu_initialised = 1;
6160      }
6261   }
6362
64   if (state->m_mcu_initialised)
63   if (m_mcu_initialised)
6564   {
6665      int i;
6766      int coin_curr;
6867
69      coin_curr = ~machine.root_device().ioport("IN0")->read() & 1;
70      if (coin_curr && !state->m_coin_last && state->m_protection_ram[0x01] < 9)
68      coin_curr = ~machine().root_device().ioport("IN0")->read() & 1;
69      if (coin_curr && !m_coin_last && m_protection_ram[0x01] < 9)
7170      {
72         state->m_protection_ram[0x01]++;    // increase credits counter
73         state->m_protection_ram[0x0a] = 0x01;   // set flag (coin inserted sound is not played otherwise)
71         m_protection_ram[0x01]++;    // increase credits counter
72         m_protection_ram[0x0a] = 0x01;   // set flag (coin inserted sound is not played otherwise)
7473      }
75      state->m_coin_last = coin_curr;
74      m_coin_last = coin_curr;
7675
77      state->m_protection_ram[0x04] = 0x3c;   // coin inputs
76      m_protection_ram[0x04] = 0x3c;   // coin inputs
7877
79      state->m_protection_ram[0x02] = BITSWAP8(machine.root_device().ioport("IN1")->read(), 7,6,5,4,2,3,1,0); // player 1
80      state->m_protection_ram[0x03] = BITSWAP8(machine.root_device().ioport("IN2")->read(), 7,6,5,4,2,3,1,0); // player 2
78      m_protection_ram[0x02] = BITSWAP8(machine().root_device().ioport("IN1")->read(), 7,6,5,4,2,3,1,0); // player 1
79      m_protection_ram[0x03] = BITSWAP8(machine().root_device().ioport("IN2")->read(), 7,6,5,4,2,3,1,0); // player 2
8180
82      if (state->m_protection_ram[0x19] == 0xaa)  // player 2 active
83         state->m_protection_ram[0x1b] = state->m_protection_ram[0x03];
81      if (m_protection_ram[0x19] == 0xaa)  // player 2 active
82         m_protection_ram[0x1b] = m_protection_ram[0x03];
8483      else
85         state->m_protection_ram[0x1b] = state->m_protection_ram[0x02];
84         m_protection_ram[0x1b] = m_protection_ram[0x02];
8685
8786
8887      for (i = 0; i < 0x10; i += 2)
89         state->m_protection_ram[i + 0xb1] = state->m_protection_ram[i + 0xb0];
88         m_protection_ram[i + 0xb1] = m_protection_ram[i + 0xb0];
9089
9190      for (i = 0; i < 0x0a; i++)
92         state->m_protection_ram[i + 0xc0] = state->m_protection_ram[i + 0x90] + 1;
91         m_protection_ram[i + 0xc0] = m_protection_ram[i + 0x90] + 1;
9392
94      if (state->m_protection_ram[0xd1] == 0xff)
93      if (m_protection_ram[0xd1] == 0xff)
9594      {
96         if (state->m_protection_ram[0xd0] > 0 && state->m_protection_ram[0xd0] < 4)
95         if (m_protection_ram[0xd0] > 0 && m_protection_ram[0xd0] < 4)
9796         {
98            state->m_protection_ram[0xd2] = 0x81;
99            state->m_protection_ram[0xd0] = 0xff;
97            m_protection_ram[0xd2] = 0x81;
98            m_protection_ram[0xd0] = 0xff;
10099         }
101100      }
102101
103      if (state->m_protection_ram[0xe0] > 0 && state->m_protection_ram[0xe0] < 4)
102      if (m_protection_ram[0xe0] > 0 && m_protection_ram[0xe0] < 4)
104103      {
105104         static const UINT8 answers[3][16] =
106105         {
r20931r20932
108107            { 0x00,0x04,0x08,0x0C,0x10,0x14,0x18,0x1C,0x20,0x31,0x2B,0x35,0x00,0x00,0x00,0x00 },
109108            { 0x00,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x03,0x0A,0x0B,0x14,0x00,0x00,0x00,0x00 },
110109         };
111         int table = state->m_protection_ram[0xe0] - 1;
110         int table = m_protection_ram[0xe0] - 1;
112111
113112         for (i = 1; i < 0x10; i++)
114            state->m_protection_ram[0xe0 + i] = answers[table][i];
115         state->m_protection_ram[0xe0] = 0xff;
113            m_protection_ram[0xe0 + i] = answers[table][i];
114         m_protection_ram[0xe0] = 0xff;
116115      }
117116
118      if (state->m_protection_ram[0xf0] > 0 && state->m_protection_ram[0xf0] < 4)
117      if (m_protection_ram[0xf0] > 0 && m_protection_ram[0xf0] < 4)
119118      {
120         state->m_protection_ram[0xf1] = 0xb3;
121         state->m_protection_ram[0xf0] = 0xff;
119         m_protection_ram[0xf1] = 0xb3;
120         m_protection_ram[0xf0] = 0xff;
122121      }
123122
124123
r20931r20932
126125      // this should be equivalent to the obfuscated kiki_clogic() below
127126      {
128127         static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
129         UINT16 sy = state->m_protection_ram[0xa0] + ((0x18) >> 1);
130         UINT16 sx = state->m_protection_ram[0xa1] + ((0x18) >> 1);
128         UINT16 sy = m_protection_ram[0xa0] + ((0x18) >> 1);
129         UINT16 sx = m_protection_ram[0xa1] + ((0x18) >> 1);
131130
132131         for (i = 0; i < 0x38; i += 8)
133132         {
134            UINT8 hw = db[state->m_protection_ram[0x20 + i] & 0xf];
133            UINT8 hw = db[m_protection_ram[0x20 + i] & 0xf];
135134
136135            if (hw)
137136            {
138               UINT16 xdiff = sx - ((UINT16)state->m_protection_ram[0x20 + i + 6] << 8 | state->m_protection_ram[0x20 + i + 7]);
137               UINT16 xdiff = sx - ((UINT16)m_protection_ram[0x20 + i + 6] << 8 | m_protection_ram[0x20 + i + 7]);
139138               if (xdiff < hw)
140139               {
141                  UINT16 ydiff = sy - ((UINT16)state->m_protection_ram[0x20 + i + 4] << 8 | state->m_protection_ram[0x20 + i + 5]);
140                  UINT16 ydiff = sy - ((UINT16)m_protection_ram[0x20 + i + 4] << 8 | m_protection_ram[0x20 + i + 5]);
142141                  if (ydiff < hw)
143                     state->m_protection_ram[0xa2] = 1; // we have a collision
142                     m_protection_ram[0xa2] = 1; // we have a collision
144143               }
145144            }
146145         }
r20931r20932
152151INTERRUPT_GEN_MEMBER(mexico86_state::kikikai_interrupt)
153152{
154153   if (m_mcu_running)
155      mcu_simulate(machine());
154      mcu_simulate();
156155
157156   device.execute().set_input_line_vector(0, m_protection_ram[0]);
158157   device.execute().set_input_line(0, HOLD_LINE);
r20931r20932
171170#define DCWIDTH 0
172171#define DCHEIGHT 0
173172
174static void kiki_clogic(running_machine &machine, int address, int latch)
173void mexico86_state::kiki_clogic(int address, int latch)
175174{
176   mexico86_state *state = machine.driver_data<mexico86_state>();
177175   static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
178176   int sy, sx, hw, i, qptr, diff1, diff2;
179177
180   if (address != KIKI_CL_TRIGGER) // state->m_queue latched data
178   if (address != KIKI_CL_TRIGGER) // m_queue latched data
181179   {
182      state->m_queue[state->m_qfront++] = latch;
183      state->m_qfront &= 0x3f;
180      m_queue[m_qfront++] = latch;
181      m_qfront &= 0x3f;
184182   }
185   else if (state->m_qstate ^= 1) // scan state->m_queue
183   else if (m_qstate ^= 1) // scan m_queue
186184   {
187      sy = state->m_queue[(state->m_qfront-0x3a)&0x3f] + ((0x18-DCHEIGHT)>>1);
188      sx = state->m_queue[(state->m_qfront-0x39)&0x3f] + ((0x18-DCWIDTH)>>1);
185      sy = m_queue[(m_qfront-0x3a)&0x3f] + ((0x18-DCHEIGHT)>>1);
186      sx = m_queue[(m_qfront-0x39)&0x3f] + ((0x18-DCWIDTH)>>1);
189187
190188      for (i=0x38; i; i-=8)
191189      {
192         qptr = state->m_qfront - i;
193         if (!(hw = db[state->m_queue[qptr&0x3f]&0xf])) continue;
190         qptr = m_qfront - i;
191         if (!(hw = db[m_queue[qptr&0x3f]&0xf])) continue;
194192
195         diff1 = sx - (short)(state->m_queue[(qptr+6)&0x3f]<<8|state->m_queue[(qptr+7)&0x3f]) + DCWIDTH;
193         diff1 = sx - (short)(m_queue[(qptr+6)&0x3f]<<8|m_queue[(qptr+7)&0x3f]) + DCWIDTH;
196194         diff2 = diff1 - (hw + DCWIDTH);
197195         if ((diff1^diff2)<0)
198196         {
199            diff1 = sy - (short)(state->m_queue[(qptr+4)&0x3f]<<8|state->m_queue[(qptr+5)&0x3f]) + DCHEIGHT;
197            diff1 = sy - (short)(m_queue[(qptr+4)&0x3f]<<8|m_queue[(qptr+5)&0x3f]) + DCHEIGHT;
200198            diff2 = diff1 - (hw + DCHEIGHT);
201199            if ((diff1^diff2)<0)
202               state->m_protection_ram[KIKI_CL_OUT] = 1; // we have a collision
200               m_protection_ram[KIKI_CL_OUT] = 1; // we have a collision
203201         }
204202      }
205203   }
trunk/src/mame/machine/midwunit.c
r20931r20932
1818 *
1919 *************************************/
2020
21static void register_state_saving(running_machine &machine)
21void midwunit_state::register_state_saving()
2222{
23   midwunit_state *state = machine.driver_data<midwunit_state>();
24   state_save_register_global(machine, state->m_cmos_write_enable);
25   state_save_register_global_array(machine, state->m_iodata);
26   state_save_register_global_array(machine, state->m_ioshuffle);
27   state_save_register_global_array(machine, state->m_uart);
28   state_save_register_global(machine, state->m_security_bits);
23   state_save_register_global(machine(), m_cmos_write_enable);
24   state_save_register_global_array(machine(), m_iodata);
25   state_save_register_global_array(machine(), m_ioshuffle);
26   state_save_register_global_array(machine(), m_uart);
27   state_save_register_global(machine(), m_security_bits);
2928}
3029
3130
r20931r20932
146145 *
147146 *************************************/
148147
149static void init_wunit_generic(running_machine &machine)
148void midwunit_state::init_wunit_generic()
150149{
151150   /* register for state saving */
152   register_state_saving(machine);
151   register_state_saving();
153152
154153   /* init sound */
155   dcs_init(machine);
154   dcs_init(machine());
156155}
157156
158157
r20931r20932
194193/*  printf("in=%04X%04X  out=%04X%04X\n", m_umk3_palette[3], m_umk3_palette[2], m_umk3_palette[1], m_umk3_palette[0]); */
195194}
196195
197static void init_mk3_common(running_machine &machine)
196void midwunit_state::init_mk3_common()
198197{
199198   /* common init */
200   init_wunit_generic(machine);
199   init_wunit_generic();
201200
202201   /* serial prefixes 439, 528 */
203   midway_serial_pic_init(machine, 528);
202   midway_serial_pic_init(machine(), 528);
204203}
205204
206205DRIVER_INIT_MEMBER(midwunit_state,mk3)
207206{
208   init_mk3_common(machine());
207   init_mk3_common();
209208}
210209
211210DRIVER_INIT_MEMBER(midwunit_state,mk3r20)
212211{
213   init_mk3_common(machine());
212   init_mk3_common();
214213}
215214
216215DRIVER_INIT_MEMBER(midwunit_state,mk3r10)
217216{
218   init_mk3_common(machine());
217   init_mk3_common();
219218}
220219
221220DRIVER_INIT_MEMBER(midwunit_state,umk3)
222221{
223   init_mk3_common(machine());
222   init_mk3_common();
224223   m_umk3_palette = machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x0106a060, 0x0106a09f, write16_delegate(FUNC(midwunit_state::umk3_palette_hack_w),this));
225224}
226225
227226DRIVER_INIT_MEMBER(midwunit_state,umk3r11)
228227{
229   init_mk3_common(machine());
228   init_mk3_common();
230229   m_umk3_palette = machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x0106a060, 0x0106a09f,write16_delegate(FUNC(midwunit_state::umk3_palette_hack_w),this));
231230}
232231
r20931r20932
236235DRIVER_INIT_MEMBER(midwunit_state,openice)
237236{
238237   /* common init */
239   init_wunit_generic(machine());
238   init_wunit_generic();
240239
241240   /* serial prefixes 438, 528 */
242241   midway_serial_pic_init(machine(), 528);
r20931r20932
248247DRIVER_INIT_MEMBER(midwunit_state,nbahangt)
249248{
250249   /* common init */
251   init_wunit_generic(machine());
250   init_wunit_generic();
252251
253252   /* serial prefixes 459, 470, 528 */
254253   midway_serial_pic_init(machine(), 528);
r20931r20932
309308DRIVER_INIT_MEMBER(midwunit_state,wwfmania)
310309{
311310   /* common init */
312   init_wunit_generic(machine());
311   init_wunit_generic();
313312
314313   /* enable I/O shuffling */
315314   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x01800000, 0x0180000f, write16_delegate(FUNC(midwunit_state::wwfmania_io_0_w),this));
r20931r20932
324323DRIVER_INIT_MEMBER(midwunit_state,rmpgwt)
325324{
326325   /* common init */
327   init_wunit_generic(machine());
326   init_wunit_generic();
328327
329328   /* serial prefixes 465, 528 */
330329   midway_serial_pic_init(machine(), 528);
trunk/src/mame/machine/mw8080bw.c
r20931r20932
1313 *
1414 *************************************/
1515
16static UINT8 vpos_to_vysnc_chain_counter( int vpos )
16UINT8 mw8080bw_state::vpos_to_vysnc_chain_counter( int vpos )
1717{
1818   /* convert from a vertical position to the actual values on the vertical sync counters */
1919   UINT8 counter;
r20931r20932
2828}
2929
3030
31static int vysnc_chain_counter_to_vpos( UINT8 counter, int vblank )
31int mw8080bw_state::vysnc_chain_counter_to_vpos( UINT8 counter, int vblank )
3232{
3333   /* convert from the vertical sync counters to an actual vertical position */
3434   int vpos;
r20931r20932
7171}
7272
7373
74static void mw8080bw_create_interrupt_timer( running_machine &machine )
74void mw8080bw_state::mw8080bw_create_interrupt_timer(  )
7575{
76   mw8080bw_state *state = machine.driver_data<mw8080bw_state>();
77   state->m_interrupt_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(mw8080bw_state::mw8080bw_interrupt_callback),state));
76   m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mw8080bw_state::mw8080bw_interrupt_callback),this));
7877}
7978
8079
81static void mw8080bw_start_interrupt_timer( running_machine &machine )
80void mw8080bw_state::mw8080bw_start_interrupt_timer(  )
8281{
83   mw8080bw_state *state = machine.driver_data<mw8080bw_state>();
8482   int vpos = vysnc_chain_counter_to_vpos(MW8080BW_INT_TRIGGER_COUNT_1, MW8080BW_INT_TRIGGER_VBLANK_1);
85   state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(vpos));
83   m_interrupt_timer->adjust(machine().primary_screen->time_until_pos(vpos));
8684}
8785
8886
r20931r20932
9593
9694MACHINE_START_MEMBER(mw8080bw_state,mw8080bw)
9795{
98   mw8080bw_create_interrupt_timer(machine());
96   mw8080bw_create_interrupt_timer();
9997
10098   m_samples = machine().device<samples_device>("samples");
10199   m_samples1 = machine().device<samples_device>("samples1");
r20931r20932
115113
116114MACHINE_RESET_MEMBER(mw8080bw_state,mw8080bw)
117115{
118   mw8080bw_start_interrupt_timer(machine());
116   mw8080bw_start_interrupt_timer();
119117}
trunk/src/mame/machine/mcr68.c
r20931r20932
1212#define VERBOSE 0
1313#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
1414
15
1615/*************************************
1716 *
18 *  Function prototypes
19 *
20 *************************************/
21
22static void subtract_from_counter(running_machine &machine, int counter, int count);
23
24/*************************************
25 *
2617 *  6821 PIA declarations
2718 *
2819 *************************************/
r20931r20932
131122}
132123
133124
134static void mcr68_common_init(running_machine &machine)
125void mcr68_state::mcr68_common_init()
135126{
136   mcr68_state *state = machine.driver_data<mcr68_state>();
137127   int i;
138128
139129   /* reset the 6840's */
140   state->m_m6840_counter_periods[0] = attotime::from_hz(30);          /* clocked by /VBLANK */
141   state->m_m6840_counter_periods[1] = attotime::never;                    /* grounded */
142   state->m_m6840_counter_periods[2] = attotime::from_hz(512 * 30);    /* clocked by /HSYNC */
130   m_m6840_counter_periods[0] = attotime::from_hz(30);          /* clocked by /VBLANK */
131   m_m6840_counter_periods[1] = attotime::never;                    /* grounded */
132   m_m6840_counter_periods[2] = attotime::from_hz(512 * 30);    /* clocked by /HSYNC */
143133
144   state->m_m6840_status = 0x00;
145   state->m_m6840_status_read_since_int = 0x00;
146   state->m_m6840_msb_buffer = state->m_m6840_lsb_buffer = 0;
134   m_m6840_status = 0x00;
135   m_m6840_status_read_since_int = 0x00;
136   m_m6840_msb_buffer = m_m6840_lsb_buffer = 0;
147137   for (i = 0; i < 3; i++)
148138   {
149      struct counter_state *m6840 = &state->m_m6840_state[i];
139      struct counter_state *m6840 = &m_m6840_state[i];
150140
151141      m6840->control = 0x00;
152142      m6840->latch = 0xffff;
153143      m6840->count = 0xffff;
154144      m6840->timer->enable(false);
155145      m6840->timer_active = 0;
156      m6840->period = state->m_m6840_counter_periods[i];
146      m6840->period = m_m6840_counter_periods[i];
157147   }
158148
159149   /* initialize the clock */
160   state->m_m6840_internal_counter_period = attotime::from_hz(machine.device("maincpu")->unscaled_clock() / 10);
150   m_m6840_internal_counter_period = attotime::from_hz(machine().device("maincpu")->unscaled_clock() / 10);
161151}
162152
163153
164154MACHINE_RESET_MEMBER(mcr68_state,mcr68)
165155{
166156   /* for the most part all MCR/68k games are the same */
167   mcr68_common_init(machine());
157   mcr68_common_init();
168158   m_v493_callback = timer_expired_delegate(FUNC(mcr68_state::mcr68_493_callback),this);
169159
170160   /* vectors are 1 and 2 */
r20931r20932
182172MACHINE_RESET_MEMBER(mcr68_state,zwackery)
183173{
184174   /* for the most part all MCR/68k games are the same */
185   mcr68_common_init(machine());
175   mcr68_common_init();
186176   m_v493_callback = timer_expired_delegate(FUNC(mcr68_state::zwackery_493_callback),this);
187177
188178   /* vectors are 5 and 6 */
r20931r20932
202192{
203193   /* update the 6840 VBLANK clock */
204194   if (!m_m6840_state[0].timer_active)
205      subtract_from_counter(machine(), 0, 1);
195      subtract_from_counter(0, 1);
206196
207197   logerror("--- VBLANK ---\n");
208198
r20931r20932
220210 *
221211 *************************************/
222212
223static void update_mcr68_interrupts(running_machine &machine)
213void mcr68_state::update_mcr68_interrupts()
224214{
225   mcr68_state *state = machine.driver_data<mcr68_state>();
226   machine.device("maincpu")->execute().set_input_line(state->m_v493_irq_vector, state->m_v493_irq_state ? ASSERT_LINE : CLEAR_LINE);
227   machine.device("maincpu")->execute().set_input_line(state->m_m6840_irq_vector, state->m_m6840_irq_state ? ASSERT_LINE : CLEAR_LINE);
215   machine().device("maincpu")->execute().set_input_line(m_v493_irq_vector, m_v493_irq_state ? ASSERT_LINE : CLEAR_LINE);
216   machine().device("maincpu")->execute().set_input_line(m_m6840_irq_vector, m_m6840_irq_state ? ASSERT_LINE : CLEAR_LINE);
228217}
229218
230219
231220TIMER_CALLBACK_MEMBER(mcr68_state::mcr68_493_off_callback)
232221{
233222   m_v493_irq_state = 0;
234   update_mcr68_interrupts(machine());
223   update_mcr68_interrupts();
235224}
236225
237226
238227TIMER_CALLBACK_MEMBER(mcr68_state::mcr68_493_callback)
239228{
240229   m_v493_irq_state = 1;
241   update_mcr68_interrupts(machine());
230   update_mcr68_interrupts();
242231   machine().scheduler().timer_set(machine().primary_screen->scan_period(), timer_expired_delegate(FUNC(mcr68_state::mcr68_493_off_callback),this));
243232   logerror("--- (INT1) ---\n");
244233}
r20931r20932
279268{
280269   pia6821_device *pia = machine().device<pia6821_device>("pia0");
281270   m_v493_irq_state = pia->irq_a_state() | pia->irq_b_state();
282   update_mcr68_interrupts(machine());
271   update_mcr68_interrupts();
283272}
284273
285274
r20931r20932
306295 *
307296 *************************************/
308297
309INLINE void update_interrupts(running_machine &machine)
298inline void mcr68_state::update_interrupts()
310299{
311   mcr68_state *state = machine.driver_data<mcr68_state>();
312   state->m_m6840_status &= ~0x80;
300   m_m6840_status &= ~0x80;
313301
314   if ((state->m_m6840_status & 0x01) && (state->m_m6840_state[0].control & 0x40)) state->m_m6840_status |= 0x80;
315   if ((state->m_m6840_status & 0x02) && (state->m_m6840_state[1].control & 0x40)) state->m_m6840_status |= 0x80;
316   if ((state->m_m6840_status & 0x04) && (state->m_m6840_state[2].control & 0x40)) state->m_m6840_status |= 0x80;
302   if ((m_m6840_status & 0x01) && (m_m6840_state[0].control & 0x40)) m_m6840_status |= 0x80;
303   if ((m_m6840_status & 0x02) && (m_m6840_state[1].control & 0x40)) m_m6840_status |= 0x80;
304   if ((m_m6840_status & 0x04) && (m_m6840_state[2].control & 0x40)) m_m6840_status |= 0x80;
317305
318   state->m_m6840_irq_state = state->m_m6840_status >> 7;
319   update_mcr68_interrupts(machine);
306   m_m6840_irq_state = m_m6840_status >> 7;
307   update_mcr68_interrupts();
320308}
321309
322310
323static void subtract_from_counter(running_machine &machine, int counter, int count)
311void mcr68_state::subtract_from_counter(int counter, int count)
324312{
325   mcr68_state *state = machine.driver_data<mcr68_state>();
326   struct counter_state *m6840 = &state->m_m6840_state[counter];
313   struct counter_state *m6840 = &m_m6840_state[counter];
327314
328315   /* dual-byte mode */
329316   if (m6840->control & 0x04)
r20931r20932
344331         /* if MSB goes less than zero, we've expired */
345332         if (msb < 0)
346333         {
347            state->m_m6840_status |= 1 << counter;
348            state->m_m6840_status_read_since_int &= ~(1 << counter);
349            update_interrupts(machine);
334            m_m6840_status |= 1 << counter;
335            m_m6840_status_read_since_int &= ~(1 << counter);
336            update_interrupts();
350337            msb = (m6840->latch >> 8) + 1;
351338            LOG(("** Counter %d fired\n", counter));
352339         }
r20931r20932
371358         word += m6840->latch + 1;
372359
373360         /* we've expired */
374         state->m_m6840_status |= 1 << counter;
375         state->m_m6840_status_read_since_int &= ~(1 << counter);
376         update_interrupts(machine);
361         m_m6840_status |= 1 << counter;
362         m_m6840_status_read_since_int &= ~(1 << counter);
363         update_interrupts();
377364         LOG(("** Counter %d fired\n", counter));
378365      }
379366
r20931r20932
393380   m6840->timer_active = 0;
394381
395382   /* subtract it all from the counter; this will generate an interrupt */
396   subtract_from_counter(machine(), counter, count);
383   subtract_from_counter(counter, count);
397384}
398385
399386
r20931r20932
508495         }
509496
510497         m_m6840_status = 0;
511         update_interrupts(machine());
498         update_interrupts();
512499      }
513500
514501      /* changing the clock source? (needed for Zwackery) */
r20931r20932
534521
535522      /* clear the interrupt */
536523      m_m6840_status &= ~(1 << counter);
537      update_interrupts(machine());
524      update_interrupts();
538525
539526      /* reload the count if in an appropriate mode */
540527      if (!(m6840->control & 0x10))
r20931r20932
568555      /* clear the interrupt if the status has been read */
569556      if (m_m6840_status_read_since_int & (1 << counter))
570557         m_m6840_status &= ~(1 << counter);
571      update_interrupts(machine());
558      update_interrupts();
572559
573560      m_m6840_lsb_buffer = result & 0xff;
574561
trunk/src/mame/machine/midxunit.c
r20931r20932
2424 *
2525 *************************************/
2626
27static void register_state_saving(running_machine &machine)
27void midxunit_state::register_state_saving()
2828{
29   midxunit_state *state = machine.driver_data<midxunit_state>();
30   state_save_register_global(machine, state->m_cmos_write_enable);
31   state_save_register_global_array(machine, state->m_iodata);
32   state_save_register_global_array(machine, state->m_ioshuffle);
33   state_save_register_global(machine, state->m_analog_port);
34   state_save_register_global_array(machine, state->m_uart);
35   state_save_register_global(machine, state->m_security_bits);
29   state_save_register_global(machine(), m_cmos_write_enable);
30   state_save_register_global_array(machine(), m_iodata);
31   state_save_register_global_array(machine(), m_ioshuffle);
32   state_save_register_global(machine(), m_analog_port);
33   state_save_register_global_array(machine(), m_uart);
34   state_save_register_global(machine(), m_security_bits);
3635}
3736
3837
r20931r20932
292291DRIVER_INIT_MEMBER(midxunit_state,revx)
293292{
294293   /* register for state saving */
295   register_state_saving(machine());
294   register_state_saving();
296295
297296   /* init sound */
298297   dcs_init(machine());
trunk/src/mame/includes/momoko.h
r20931r20932
4646   virtual void machine_start();
4747   virtual void machine_reset();
4848   UINT32 screen_update_momoko(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
49   void momoko_draw_bg_pri( bitmap_ind16 &bitmap, int chr, int col, int flipx, int flipy, int x, int y, int pri );
4950};
trunk/src/mame/includes/midwunit.h
r20931r20932
4141   DECLARE_DRIVER_INIT(mk3r20);
4242   DECLARE_MACHINE_RESET(midwunit);
4343   DECLARE_VIDEO_START(midwunit);
44   void register_state_saving();
45   void init_wunit_generic();
46   void init_mk3_common();
4447};
trunk/src/mame/includes/m107.h
r20931r20932
5353   virtual void video_start();
5454   UINT32 screen_update_m107(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   TIMER_DEVICE_CALLBACK_MEMBER(m107_scanline_interrupt);
56   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
57   void m107_update_scroll_positions();
58   void m107_tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int laynum, int category,int opaque);
59   void m107_screenrefresh(bitmap_ind16 &bitmap, const rectangle &cliprect);
5660};
trunk/src/mame/includes/m52.h
r20931r20932
3535   virtual void video_start();
3636   virtual void palette_init();
3737   UINT32 screen_update_m52(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
38   void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int xpos, int ypos, int image);
3839};
trunk/src/mame/includes/madalien.h
r20931r20932
6363   DECLARE_VIDEO_START(madalien);
6464   DECLARE_PALETTE_INIT(madalien);
6565   UINT32 screen_update_madalien(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
66   inline int scan_helper(int col, int row, int section);
67   void draw_edges(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip, int scroll_mode);
68   void draw_headlight(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip);
69   void draw_foreground(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip);
70   inline UINT8 shift_common(UINT8 hi, UINT8 lo);
6671};
6772/*----------- defined in video/madalien.c -----------*/
6873
trunk/src/mame/includes/mermaid.h
r20931r20932
8080   UINT32 screen_update_mermaid(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8181   void screen_eof_mermaid(screen_device &screen, bool state);
8282   INTERRUPT_GEN_MEMBER(vblank_irq);
83   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
84   UINT8 collision_check( rectangle& rect );
8385};
trunk/src/mame/includes/metro.h
r20931r20932
178178   TIMER_CALLBACK_MEMBER(metro_blit_done);
179179   void update_irq_state();
180180   IRQ_CALLBACK_MEMBER(metro_irq_callback);
181   inline UINT8 get_tile_pix( UINT16 code, UINT8 x, UINT8 y, int big, UINT16 *pix );
182   inline void metro_vram_w( offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram );
183   void metro_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
184   void draw_layers( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int layers_ctrl );
185   inline int blt_read( const UINT8 *ROM, const int offs );
186   void metro_common(  );
187   void draw_tilemap( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 flags, UINT32 pcode,
188               int sx, int sy, int wx, int wy, int big, UINT16 *tilemapram, int layer );
181189};
182190
183191
trunk/src/mame/includes/mikie.h
r20931r20932
4545   virtual void palette_init();
4646   UINT32 screen_update_mikie(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4747   INTERRUPT_GEN_MEMBER(vblank_irq);
48   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4849};
trunk/src/mame/includes/m62.h
r20931r20932
106106   UINT32 screen_update_spelunk2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
107107   UINT32 screen_update_youjyudn(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
108108   UINT32 screen_update_horizon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
109   void m62_amplify_contrast(palette_t *palette, UINT32 numcolors);
110   void register_savestate(  );
111   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int colormask, int prioritymask, int priority );
112   void m62_start( tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 );
113   void m62_textlayer( tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 );
109114};
trunk/src/mame/includes/mustache.h
r20931r20932
1919   virtual void palette_init();
2020   UINT32 screen_update_mustache(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2121   TIMER_DEVICE_CALLBACK_MEMBER(mustache_scanline);
22   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
2223};
trunk/src/mame/includes/mcatadv.h
r20931r20932
4343   virtual void video_start();
4444   UINT32 screen_update_mcatadv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4545   void screen_eof_mcatadv(screen_device &screen, bool state);
46   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
47   void mcatadv_draw_tilemap_part( UINT16* current_scroll, UINT16* current_videoram1, int i, tilemap_t* current_tilemap, bitmap_ind16 &bitmap, const rectangle &cliprect );
4648};
trunk/src/mame/includes/midxunit.h
r20931r20932
3737   DECLARE_DRIVER_INIT(revx);
3838   DECLARE_MACHINE_RESET(midxunit);
3939   DECLARE_VIDEO_START(midxunit);
40   void register_state_saving();
4041};
trunk/src/mame/includes/munchmo.h
r20931r20932
4949   UINT32 screen_update_mnchmobl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   INTERRUPT_GEN_MEMBER(mnchmobl_vblank_irq);
5151   INTERRUPT_GEN_MEMBER(mnchmobl_sound_irq);
52   void draw_status( bitmap_ind16 &bitmap, const rectangle &cliprect );
53   void draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect );
54   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5255};
trunk/src/mame/includes/mugsmash.h
r20931r20932
3131   virtual void machine_start();
3232   virtual void video_start();
3333   UINT32 screen_update_mugsmash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
34   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
3435};
trunk/src/mame/includes/macrossp.h
r20931r20932
7373   virtual void video_start();
7474   UINT32 screen_update_macrossp(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
7575   void screen_eof_macrossp(screen_device &screen, bool state);
76   void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority );
77   void draw_layer( bitmap_rgb32 &bitmap, const rectangle &cliprect, int layer );
78   void sortlayers(int *layer,int *pri);
79   void update_colors(  );
7680};
trunk/src/mame/includes/m72.h
r20931r20932
123123   TIMER_CALLBACK_MEMBER(m72_scanline_interrupt);
124124   TIMER_CALLBACK_MEMBER(kengo_scanline_interrupt);
125125   TIMER_CALLBACK_MEMBER(delayed_ram16_w);
126   inline void m72_get_tile_info(tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum);
127   inline void rtype2_get_tile_info(tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum);
128   void register_savestate();
129   inline void changecolor(int color,int r,int g,int b);
130   void m72_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
131   void majtitle_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
132   int find_sample(int num);
133   void copy_le(UINT16 *dest, const UINT8 *src, UINT8 bytes);
134   void install_protection_handler(const UINT8 *code,const UINT8 *crc);
126135};
trunk/src/mame/includes/megasys1.h
r20931r20932
116116   INTERRUPT_GEN_MEMBER(megasys1D_irq);
117117   TIMER_DEVICE_CALLBACK_MEMBER(megasys1A_scanline);
118118   TIMER_DEVICE_CALLBACK_MEMBER(megasys1B_scanline);
119   inline void scrollram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int which);
120   void create_tilemaps();
121   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
122   void rodlandj_gfx_unmangle(const char *region);
123   void jitsupro_gfx_unmangle(const char *region);
124   void stdragona_gfx_unmangle(const char *region);
119125};
trunk/src/mame/includes/m90.h
r20931r20932
4848   INTERRUPT_GEN_MEMBER(m90_interrupt);
4949   INTERRUPT_GEN_MEMBER(dynablsb_interrupt);
5050   INTERRUPT_GEN_MEMBER(bomblord_interrupt);
51   inline void get_tile_info(tile_data &tileinfo,int tile_index,int layer,int page_mask);
52   inline void bomblord_get_tile_info(tile_data &tileinfo,int tile_index,int layer);
53   inline void dynablsb_get_tile_info(tile_data &tileinfo,int tile_index,int layer);
54   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
55   void bomblord_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
56   void dynablsb_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
57   void markdirty(tilemap_t *tmap,int page,offs_t offset);
5158};
trunk/src/mame/includes/ms32.h
r20931r20932
9292   IRQ_CALLBACK_MEMBER(irq_callback);
9393   void irq_init();
9494   void irq_raise(int level);
95   void update_color(int color);
96   void draw_sprites(bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_pri, const rectangle &cliprect, UINT16 *sprram_top, size_t sprram_size, int gfxnum, int reverseorder);
97   void draw_roz(bitmap_ind16 &bitmap, const rectangle &cliprect,int priority);
98   void configure_banks();
9599};
trunk/src/mame/includes/mcr3.h
r20931r20932
6565   DECLARE_PALETTE_INIT(spyhunt);
6666   UINT32 screen_update_mcr3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6767   UINT32 screen_update_spyhunt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
68   void mcr3_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int code_xor, int dx, int dy);
69   void mcr_common_init();
6870};
trunk/src/mame/includes/mitchell.h
r20931r20932
104104   DECLARE_VIDEO_START(pang);
105105   UINT32 screen_update_pang(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
106106   TIMER_DEVICE_CALLBACK_MEMBER(mitchell_irq);
107   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
108   void bootleg_decode(  );
109   void configure_banks(  );
107110};
trunk/src/mame/includes/m57.h
r20931r20932
2121   virtual void video_start();
2222   virtual void palette_init();
2323   UINT32 screen_update_m57(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
24   void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect);
25   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
2426};
trunk/src/mame/includes/mcr68.h
r20931r20932
109109   DECLARE_WRITE8_MEMBER(zwackery_pia1_w);
110110   DECLARE_WRITE_LINE_MEMBER(zwackery_ca2_w);
111111   DECLARE_WRITE_LINE_MEMBER(zwackery_pia_irq);
112   void mcr68_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
113   void zwackery_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
114   void mcr68_common_init();
115   void update_mcr68_interrupts();
116   inline void update_interrupts();
117   void subtract_from_counter(int counter, int count);
118   void mcr68_common_init(int clip, int xoffset);
112119};
113120
114121/*----------- defined in machine/mcr68.c -----------*/
trunk/src/mame/includes/mystston.h
r20931r20932
4848   DECLARE_VIDEO_RESET(mystston);
4949   UINT32 screen_update_mystston(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   TIMER_CALLBACK_MEMBER(interrupt_callback);
51   void set_palette();
52   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, int flip);
53   void mystston_on_scanline_interrupt();
5154};
5255
53/*----------- defined in drivers/mystston.c -----------*/
54
55void mystston_on_scanline_interrupt(running_machine &machine);
56
5756/*----------- defined in video/mystston.c -----------*/
5857
5958MACHINE_CONFIG_EXTERN( mystston_video );
trunk/src/mame/includes/mario.h
r20931r20932
9090   DECLARE_WRITE8_MEMBER(mario_sh_sound_w);
9191   DECLARE_WRITE8_MEMBER(mario_sh1_w);
9292   DECLARE_WRITE8_MEMBER(mario_sh2_w);
93   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
9394};
9495
9596/*----------- defined in audio/mario.c -----------*/
trunk/src/mame/includes/maygay1b.h
r20931r20932
8181   DECLARE_DRIVER_INIT(m1);
8282   virtual void machine_start();
8383   virtual void machine_reset();
84   void update_outputs(i8279_state *chip, UINT16 which);
85   void m1_stepper_reset();
8486};
trunk/src/mame/includes/m92.h
r20931r20932
7979   UINT32 screen_update_ppan(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8080   TIMER_CALLBACK_MEMBER(spritebuffer_callback);
8181   TIMER_DEVICE_CALLBACK_MEMBER(m92_scanline_interrupt);
82   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
83   void ppan_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
84   void m92_update_scroll_positions();
85   void m92_draw_tiles(bitmap_ind16 &bitmap,const rectangle &cliprect);
86   void m92_sprite_interrupt();
8287};
8388
8489/*----------- defined in drivers/m92.c -----------*/
trunk/src/mame/includes/m58.h
r20931r20932
3131   virtual void video_start();
3232   virtual void palette_init();
3333   UINT32 screen_update_yard(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
34   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
35   void draw_panel( bitmap_ind16 &bitmap, const rectangle &cliprect );
3436};
trunk/src/mame/includes/mappy.h
r20931r20932
6262   TIMER_CALLBACK_MEMBER(pacnpal_io_run);
6363   TIMER_CALLBACK_MEMBER(phozon_io_run);
6464   TIMER_CALLBACK_MEMBER(mappy_io_run);
65   void mappy_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base);
66   void phozon_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base);
6567};
trunk/src/mame/includes/mcr.h
r20931r20932
109109   DECLARE_WRITE16_MEMBER(mcr_ipu_sio_transmit);
110110   DECLARE_WRITE_LINE_MEMBER(ipu_ctc_interrupt);
111111   DECLARE_WRITE8_MEMBER(ipu_break_changed);
112   void mcr_set_color(int index, int data);
113   void journey_set_color(int index, int data);
114   void render_sprites_91399(bitmap_ind16 &bitmap, const rectangle &cliprect);
115   void render_sprites_91464(bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int sprmask, int colormask);
116   void mcr_init(int cpuboard, int vidboard, int ssioboard);
112117};
113118
114119/*----------- defined in machine/mcr.c -----------*/
trunk/src/mame/includes/meadows.h
r20931r20932
4949   INTERRUPT_GEN_MEMBER(meadows_interrupt);
5050   INTERRUPT_GEN_MEMBER(minferno_interrupt);
5151   INTERRUPT_GEN_MEMBER(audio_interrupt);
52   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &clip);
5253};
5354
5455
trunk/src/mame/includes/mexico86.h
r20931r20932
5757   UINT32 screen_update_kikikai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5858   INTERRUPT_GEN_MEMBER(kikikai_interrupt);
5959   INTERRUPT_GEN_MEMBER(mexico86_m68705_interrupt);
60   void mcu_simulate(  );
61   void kiki_clogic(int address, int latch);
6062};
trunk/src/mame/includes/m10.h
r20931r20932
9494   TIMER_CALLBACK_MEMBER(interrupt_callback);
9595   DECLARE_WRITE8_MEMBER(ic8j1_output_changed);
9696   DECLARE_WRITE8_MEMBER(ic8j2_output_changed);
97   inline void plot_pixel_m10( bitmap_ind16 &bm, int x, int y, int col );
9798};
trunk/src/mame/includes/metlclsh.h
r20931r20932
5050   virtual void machine_reset();
5151   virtual void video_start();
5252   UINT32 screen_update_metlclsh(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
53   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5354};
trunk/src/mame/includes/markham.h
r20931r20932
2727   virtual void video_start();
2828   virtual void palette_init();
2929   UINT32 screen_update_markham(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
30   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
3031};
trunk/src/mame/includes/msisaac.h
r20931r20932
7474   DECLARE_MACHINE_RESET(ta7630);
7575   UINT32 screen_update_msisaac(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7676   TIMER_CALLBACK_MEMBER(nmi_callback);
77   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
7778};
trunk/src/mame/includes/mw8080bw.h
r20931r20932
174174   DECLARE_WRITE8_MEMBER(invad2ct_audio_3_w);
175175   DECLARE_WRITE8_MEMBER(invad2ct_audio_4_w);
176176   void maze_update_discrete();
177   UINT8 vpos_to_vysnc_chain_counter( int vpos );
178   int vysnc_chain_counter_to_vpos( UINT8 counter, int vblank );
179   void mw8080bw_create_interrupt_timer(  );
180   void mw8080bw_start_interrupt_timer(  );
181   UINT8 tornbase_get_cabinet_type();
182   UINT8 spcenctr_get_trench_width();
183   UINT8 spcenctr_get_trench_center();
184   UINT8 spcenctr_get_trench_slope(UINT8 addr );
185   int invaders_is_cabinet_cocktail();
186   UINT32 invad2ct_coin_input_r(void *param);
177187};
178188
179189
trunk/src/mame/includes/mrflea.h
r20931r20932
4646   virtual void machine_reset();
4747   UINT32 screen_update_mrflea(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4848   TIMER_DEVICE_CALLBACK_MEMBER(mrflea_slave_interrupt);
49   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
50   void draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect );
4951};
trunk/src/mame/includes/marineb.h
r20931r20932
4646   UINT32 screen_update_hopprobo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4747   INTERRUPT_GEN_MEMBER(marineb_vblank_irq);
4848   INTERRUPT_GEN_MEMBER(wanted_vblank_irq);
49   void set_tilemap_scrolly( int cols );
4950};
trunk/src/mame/includes/mrdo.h
r20931r20932
3333   virtual void video_start();
3434   virtual void palette_init();
3535   UINT32 screen_update_mrdo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
36   void draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect );
3637};
trunk/src/mame/includes/mjkjidai.h
r20931r20932
3030   virtual void video_start();
3131   UINT32 screen_update_mjkjidai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3232   INTERRUPT_GEN_MEMBER(vblank_irq);
33   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
3334};
trunk/src/mame/includes/mainsnk.h
r20931r20932
2828   virtual void video_start();
2929   virtual void palette_init();
3030   UINT32 screen_update_mainsnk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
31   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int scrollx, int scrolly );
3132};
trunk/src/mame/includes/mrjong.h
r20931r20932
2626   virtual void video_start();
2727   virtual void palette_init();
2828   UINT32 screen_update_mrjong(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
29   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
2930};
trunk/src/mame/video/mrdo.c
r20931r20932
233233
234234***************************************************************************/
235235
236static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect )
236void mrdo_state::draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect )
237237{
238   mrdo_state *state = machine.driver_data<mrdo_state>();
239   UINT8 *spriteram = state->m_spriteram;
238   UINT8 *spriteram = m_spriteram;
240239   int offs;
241240
242   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
241   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
243242   {
244243      if (spriteram[offs + 1] != 0)
245244      {
246         drawgfx_transpen(bitmap, cliprect, machine.gfx[2],
245         drawgfx_transpen(bitmap, cliprect, machine().gfx[2],
247246               spriteram[offs], spriteram[offs + 2] & 0x0f,
248247               spriteram[offs + 2] & 0x10, spriteram[offs + 2] & 0x20,
249248               spriteram[offs + 3], 256 - spriteram[offs + 1], 0);
r20931r20932
256255   bitmap.fill(0, cliprect);
257256   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
258257   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
259   draw_sprites(machine(), bitmap, cliprect);
258   draw_sprites(bitmap, cliprect);
260259   return 0;
261260}
trunk/src/mame/video/mugsmash.c
r20931r20932
33#include "emu.h"
44#include "includes/mugsmash.h"
55
6static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
6void mugsmash_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
77{
88   /* Each Sprite takes 16 bytes, 5 used? */
99
r20931r20932
2424
2525   */
2626
27   mugsmash_state *state = machine.driver_data<mugsmash_state>();
28   const UINT16 *source = state->m_spriteram;
27   const UINT16 *source = m_spriteram;
2928   const UINT16 *finish = source + 0x2000;
30   gfx_element *gfx = machine.gfx[0];
29   gfx_element *gfx = machine().gfx[0];
3130
3231   while (source < finish)
3332   {
r20931r20932
142141{
143142   m_tilemap2->draw(bitmap, cliprect, 0, 0);
144143   m_tilemap1->draw(bitmap, cliprect, 0, 0);
145   draw_sprites(machine(), bitmap, cliprect);
144   draw_sprites(bitmap, cliprect);
146145   return 0;
147146}
trunk/src/mame/video/macrossp.c
r20931r20932
159159
160160
161161
162static void draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority )
162void macrossp_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority )
163163{
164   macrossp_state *state = machine.driver_data<macrossp_state>();
165   gfx_element *gfx = machine.gfx[0];
166   //  UINT32 *source = state->m_spriteram;
167   UINT32 *source = state->m_spriteram_old2; /* buffers by two frames */
168   UINT32 *finish = source + state->m_spriteram.bytes() / 4;
164   gfx_element *gfx = machine().gfx[0];
165   //  UINT32 *source = m_spriteram;
166   UINT32 *source = m_spriteram_old2; /* buffers by two frames */
167   UINT32 *finish = source + m_spriteram.bytes() / 4;
169168
170169   while (source < finish)
171170   {
r20931r20932
217216               break;
218217
219218            default:
220               col = machine.rand();
219               col = machine().rand();
221220               break;
222221         }
223222
r20931r20932
305304}
306305
307306
308static void draw_layer( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int layer )
307void macrossp_state::draw_layer( bitmap_rgb32 &bitmap, const rectangle &cliprect, int layer )
309308{
310   macrossp_state *state = machine.driver_data<macrossp_state>();
311309   tilemap_t *tm;
312310   UINT32 *vr;
313311
r20931r20932
315313   {
316314      case 0:
317315      default:
318         tm = state->m_scra_tilemap;
319         vr = state->m_scra_videoregs;
316         tm = m_scra_tilemap;
317         vr = m_scra_videoregs;
320318         break;
321319
322320      case 1:
323         tm = state->m_scrb_tilemap;
324         vr = state->m_scrb_videoregs;
321         tm = m_scrb_tilemap;
322         vr = m_scrb_videoregs;
325323         break;
326324
327325      case 2:
328         tm = state->m_scrc_tilemap;
329         vr = state->m_scrc_videoregs;
326         tm = m_scrc_tilemap;
327         vr = m_scrc_videoregs;
330328         break;
331329   }
332330
r20931r20932
357355}
358356
359357/* useful function to sort the three tile layers by priority order */
360static void sortlayers(int *layer,int *pri)
358void macrossp_state::sortlayers(int *layer,int *pri)
361359{
362360#define SWAP(a,b) \
363361   if (pri[a] >= pri[b]) \
r20931r20932
387385
388386   sortlayers(layers, layerpri);
389387
390   draw_layer(machine(), bitmap, cliprect, layers[0]);
391   draw_sprites(machine(), bitmap, cliprect, 0);
392   draw_layer(machine(), bitmap, cliprect, layers[1]);
393   draw_sprites(machine(), bitmap, cliprect, 1);
394   draw_layer(machine(), bitmap, cliprect, layers[2]);
395   draw_sprites(machine(), bitmap, cliprect, 2);
396   draw_sprites(machine(), bitmap, cliprect, 3);
388   draw_layer(bitmap, cliprect, layers[0]);
389   draw_sprites(bitmap, cliprect, 0);
390   draw_layer(bitmap, cliprect, layers[1]);
391   draw_sprites(bitmap, cliprect, 1);
392   draw_layer(bitmap, cliprect, layers[2]);
393   draw_sprites(bitmap, cliprect, 2);
394   draw_sprites(bitmap, cliprect, 3);
397395   m_text_tilemap->draw(bitmap, cliprect, 0, 0);
398396
399397#if 0
trunk/src/mame/video/momoko.c
r20931r20932
6666
6767/****************************************************************************/
6868
69static void momoko_draw_bg_pri( running_machine &machine, bitmap_ind16 &bitmap, int chr, int col, int flipx, int flipy, int x, int y, int pri )
69void momoko_state::momoko_draw_bg_pri( bitmap_ind16 &bitmap, int chr, int col, int flipx, int flipy, int x, int y, int pri )
7070{
7171   int xx, sx, sy, px, py, dot;
7272   UINT32 gfxadr;
7373   UINT8 d0, d1;
74   UINT8 *BG_GFX = machine.root_device().memregion("gfx2")->base();
74   UINT8 *BG_GFX = machine().root_device().memregion("gfx2")->base();
7575
7676   for (sy = 0; sy < 8; sy++)
7777   {
r20931r20932
210210            {
211211               col = col & 0x0f;
212212               chr = chr + m_bg_select * 512;
213               momoko_draw_bg_pri(machine(), bitmap, chr, col, flip, flip, px, py, pri);
213               momoko_draw_bg_pri(bitmap, chr, col, flip, flip, px, py, pri);
214214            }
215215         }
216216      }
trunk/src/mame/video/mcr68.c
r20931r20932
195195 *
196196 *************************************/
197197
198static void mcr68_update_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
198void mcr68_state::mcr68_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
199199{
200   mcr68_state *state = machine.driver_data<mcr68_state>();
201   rectangle sprite_clip = machine.primary_screen->visible_area();
202   UINT16 *spriteram = state->m_spriteram;
200   rectangle sprite_clip = machine().primary_screen->visible_area();
201   UINT16 *spriteram = m_spriteram;
203202   int offs;
204203
205204   /* adjust for clipping */
206   sprite_clip.min_x += state->m_sprite_clip;
207   sprite_clip.max_x -= state->m_sprite_clip;
205   sprite_clip.min_x += m_sprite_clip;
206   sprite_clip.max_x -= m_sprite_clip;
208207   sprite_clip &= cliprect;
209208
210   machine.priority_bitmap.fill(1, sprite_clip);
209   machine().priority_bitmap.fill(1, sprite_clip);
211210
212211   /* loop over sprite RAM */
213   for (offs = state->m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4)
212   for (offs = m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4)
214213   {
215214      int code, color, flipx, flipy, x, y, flags;
216215
r20931r20932
229228      color = ~flags & 0x03;
230229      flipx = flags & 0x10;
231230      flipy = flags & 0x20;
232      x = LOW_BYTE(spriteram[offs + 3]) * 2 + state->m_sprite_xoffset;
231      x = LOW_BYTE(spriteram[offs + 3]) * 2 + m_sprite_xoffset;
233232      y = (241 - LOW_BYTE(spriteram[offs])) * 2;
234233
235234      /* allow sprites to clip off the left side */
r20931r20932
239238          The color 8 is used to cover over other sprites. */
240239
241240      /* first draw the sprite, visible */
242      pdrawgfx_transmask(bitmap, sprite_clip, machine.gfx[1], code, color, flipx, flipy, x, y,
243            machine.priority_bitmap, 0x00, 0x0101);
241      pdrawgfx_transmask(bitmap, sprite_clip, machine().gfx[1], code, color, flipx, flipy, x, y,
242            machine().priority_bitmap, 0x00, 0x0101);
244243
245244      /* then draw the mask, behind the background but obscuring following sprites */
246      pdrawgfx_transmask(bitmap, sprite_clip, machine.gfx[1], code, color, flipx, flipy, x, y,
247            machine.priority_bitmap, 0x02, 0xfeff);
245      pdrawgfx_transmask(bitmap, sprite_clip, machine().gfx[1], code, color, flipx, flipy, x, y,
246            machine().priority_bitmap, 0x02, 0xfeff);
248247   }
249248}
250249
251250
252static void zwackery_update_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
251void mcr68_state::zwackery_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority)
253252{
254   mcr68_state *state = machine.driver_data<mcr68_state>();
255   UINT16 *spriteram = state->m_spriteram;
253   UINT16 *spriteram = m_spriteram;
256254   int offs;
257255
258   machine.priority_bitmap.fill(1, cliprect);
256   machine().priority_bitmap.fill(1, cliprect);
259257
260258   /* loop over sprite RAM */
261   for (offs = state->m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4)
259   for (offs = m_spriteram.bytes() / 2 - 4;offs >= 0;offs -= 4)
262260   {
263261      int code, color, flipx, flipy, x, y, flags;
264262
r20931r20932
297295          The color 8 is used to cover over other sprites. */
298296
299297      /* first draw the sprite, visible */
300      pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, x, y,
301            machine.priority_bitmap, 0x00, 0x0101);
298      pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, x, y,
299            machine().priority_bitmap, 0x00, 0x0101);
302300
303301      /* then draw the mask, behind the background but obscuring following sprites */
304      pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, x, y,
305            machine.priority_bitmap, 0x02, 0xfeff);
302      pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, x, y,
303            machine().priority_bitmap, 0x02, 0xfeff);
306304   }
307305}
308306
r20931r20932
320318   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0);
321319
322320   /* draw the low-priority sprites */
323   mcr68_update_sprites(machine(), bitmap, cliprect, 0);
321   mcr68_update_sprites(bitmap, cliprect, 0);
324322
325323   /* redraw tiles with priority over sprites */
326324   m_bg_tilemap->draw(bitmap, cliprect, 1, 0);
327325
328326   /* draw the high-priority sprites */
329   mcr68_update_sprites(machine(), bitmap, cliprect, 1);
327   mcr68_update_sprites(bitmap, cliprect, 1);
330328   return 0;
331329}
332330
r20931r20932
337335   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
338336
339337   /* draw the low-priority sprites */
340   zwackery_update_sprites(machine(), bitmap, cliprect, 0);
338   zwackery_update_sprites(bitmap, cliprect, 0);
341339
342340   /* redraw tiles with priority over sprites */
343341   m_fg_tilemap->draw(bitmap, cliprect, 1, 0);
344342
345343   /* draw the high-priority sprites */
346   zwackery_update_sprites(machine(), bitmap, cliprect, 1);
344   zwackery_update_sprites(bitmap, cliprect, 1);
347345   return 0;
348346}
trunk/src/mame/video/m62.c
r20931r20932
180180};
181181
182182
183static void m62_amplify_contrast(palette_t *palette, UINT32 numcolors)
183void m62_state::m62_amplify_contrast(palette_t *palette, UINT32 numcolors)
184184{
185185   // m62 palette is very dark, so amplify default contrast
186186   UINT32 i, ymax=1;
r20931r20932
283283}
284284
285285
286static void register_savestate( running_machine &machine )
286void m62_state::register_savestate(  )
287287{
288   m62_state *state = machine.driver_data<m62_state>();
289288
290   state->save_item(NAME(state->m_flipscreen));
291   state->save_item(NAME(state->m_m62_background_hscroll));
292   state->save_item(NAME(state->m_m62_background_vscroll));
289   save_item(NAME(m_flipscreen));
290   save_item(NAME(m_m62_background_hscroll));
291   save_item(NAME(m_m62_background_vscroll));
293292
294   state->save_item(NAME(state->m_kidniki_background_bank));
295   state->save_item(NAME(state->m_kidniki_text_vscroll));
296   state->save_item(NAME(state->m_ldrun3_topbottom_mask));
297   state->save_item(NAME(state->m_spelunkr_palbank));
293   save_item(NAME(m_kidniki_background_bank));
294   save_item(NAME(m_kidniki_text_vscroll));
295   save_item(NAME(m_ldrun3_topbottom_mask));
296   save_item(NAME(m_spelunkr_palbank));
298297}
299298
300299
r20931r20932
346345}
347346
348347
349static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int colormask, int prioritymask, int priority )
348void m62_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int colormask, int prioritymask, int priority )
350349{
351   m62_state *state = machine.driver_data<m62_state>();
352350   int offs;
353351
354   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 8)
352   for (offs = 0; offs < m_spriteram.bytes(); offs += 8)
355353   {
356354      int i, incr, code, col, flipx, flipy, sx, sy;
357355
358      if ((state->m_spriteram[offs] & prioritymask) == priority)
356      if ((m_spriteram[offs] & prioritymask) == priority)
359357      {
360         code = state->m_spriteram[offs + 4] + ((state->m_spriteram[offs + 5] & 0x07) << 8);
361         col = state->m_spriteram[offs + 0] & colormask;
362         sx = 256 * (state->m_spriteram[offs + 7] & 1) + state->m_spriteram[offs + 6],
363         sy = 256 + 128 - 15 - (256 * (state->m_spriteram[offs + 3] & 1) + state->m_spriteram[offs + 2]),
364         flipx = state->m_spriteram[offs + 5] & 0x40;
365         flipy = state->m_spriteram[offs + 5] & 0x80;
358         code = m_spriteram[offs + 4] + ((m_spriteram[offs + 5] & 0x07) << 8);
359         col = m_spriteram[offs + 0] & colormask;
360         sx = 256 * (m_spriteram[offs + 7] & 1) + m_spriteram[offs + 6],
361         sy = 256 + 128 - 15 - (256 * (m_spriteram[offs + 3] & 1) + m_spriteram[offs + 2]),
362         flipx = m_spriteram[offs + 5] & 0x40;
363         flipy = m_spriteram[offs + 5] & 0x80;
366364
367         i = state->m_sprite_height_prom[(code >> 5) & 0x1f];
365         i = m_sprite_height_prom[(code >> 5) & 0x1f];
368366         if (i == 1) /* double height */
369367         {
370368            code &= ~1;
r20931r20932
377375            sy -= 3*16;
378376         }
379377
380         if (state->m_flipscreen)
378         if (m_flipscreen)
381379         {
382380            sx = 496 - sx;
383381            sy = 242 - i*16 - sy;   /* sprites are slightly misplaced by the hardware */
r20931r20932
394392
395393         do
396394         {
397            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
395            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
398396                  code + i * incr,col,
399397                  flipx,flipy,
400398                  sx,sy + 16 * i,0);
r20931r20932
405403   }
406404}
407405
408static void m62_start( running_machine &machine, tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
406void m62_state::m62_start( tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
409407{
410   m62_state *state = machine.driver_data<m62_state>();
411   state->m_bg_tilemap = &machine.tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS,  x1, y1, x2, y2);
408   m_bg_tilemap = &machine().tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS,  x1, y1, x2, y2);
412409
413   register_savestate(machine);
410   register_savestate();
414411
415412   if (rows != 0)
416      state->m_bg_tilemap->set_scroll_rows(rows);
413      m_bg_tilemap->set_scroll_rows(rows);
417414
418415   if (cols != 0)
419      state->m_bg_tilemap->set_scroll_cols(cols);
416      m_bg_tilemap->set_scroll_cols(cols);
420417}
421418
422static void m62_textlayer( running_machine &machine, tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
419void m62_state::m62_textlayer( tilemap_get_info_delegate tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
423420{
424   m62_state *state = machine.driver_data<m62_state>();
425   state->m_fg_tilemap = &machine.tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS,  x1, y1, x2, y2);
421   m_fg_tilemap = &machine().tilemap().create(tile_get_info, TILEMAP_SCAN_ROWS,  x1, y1, x2, y2);
426422
427423   if (rows != 0)
428      state->m_fg_tilemap->set_scroll_rows(rows);
424      m_fg_tilemap->set_scroll_rows(rows);
429425
430426   if (cols != 0)
431      state->m_fg_tilemap->set_scroll_cols(cols);
427      m_fg_tilemap->set_scroll_cols(cols);
432428}
433429
434430WRITE8_MEMBER(m62_state::kungfum_tileram_w)
r20931r20932
460456
461457VIDEO_START_MEMBER(m62_state,kungfum)
462458{
463   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_kungfum_bg_tile_info),this), 32, 0, 8, 8, 64, 32);
459   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_kungfum_bg_tile_info),this), 32, 0, 8, 8, 64, 32);
464460}
465461
466462UINT32 m62_state::screen_update_kungfum(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20931r20932
475471      m_bg_tilemap->set_scrollx(i, m_m62_background_hscroll);
476472   }
477473   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
478   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
474   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
479475   m_bg_tilemap->draw(bitmap, cliprect, 1, 0);
480476   return 0;
481477}
r20931r20932
502498
503499void m62_state::video_start()
504500{
505   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_ldrun_bg_tile_info),this), 1, 1, 8, 8, 64, 32);
501   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_ldrun_bg_tile_info),this), 1, 1, 8, 8, 64, 32);
506502   m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */
507503   m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */
508504}
r20931r20932
513509   m_bg_tilemap->set_scrolly(0, m_m62_background_vscroll);
514510
515511   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
516   draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x00);
512   draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x00);
517513   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
518   draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x10);
514   draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x10);
519515   return 0;
520516}
521517
r20931r20932
540536
541537VIDEO_START_MEMBER(m62_state,ldrun2)
542538{
543   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_ldrun2_bg_tile_info),this), 1, 1, 8, 8, 64, 32);
539   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_ldrun2_bg_tile_info),this), 1, 1, 8, 8, 64, 32);
544540   m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */
545541   m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */
546542}
r20931r20932
602598
603599VIDEO_START_MEMBER(m62_state,battroad)
604600{
605   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_battroad_bg_tile_info),this), 1, 1, 8, 8, 64, 32);
606   m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_battroad_fg_tile_info),this), 1, 1, 8, 8, 32, 32);
601   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_battroad_bg_tile_info),this), 1, 1, 8, 8, 64, 32);
602   m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_battroad_fg_tile_info),this), 1, 1, 8, 8, 32, 32);
607603   m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */
608604   m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */
609605}
r20931r20932
617613   m_fg_tilemap->set_transparent_pen(0);
618614
619615   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
620   draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x00);
616   draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x00);
621617   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
622   draw_sprites(machine(), bitmap, cliprect, 0x0f, 0x10, 0x10);
618   draw_sprites(bitmap, cliprect, 0x0f, 0x10, 0x10);
623619   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
624620   return 0;
625621}
r20931r20932
638634
639635VIDEO_START_MEMBER(m62_state,ldrun4)
640636{
641   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_ldrun4_bg_tile_info),this), 1, 0, 8, 8, 64, 32);
637   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_ldrun4_bg_tile_info),this), 1, 0, 8, 8, 64, 32);
642638}
643639
644640UINT32 m62_state::screen_update_ldrun4(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20931r20932
646642   m_bg_tilemap->set_scrollx(0, m_m62_background_hscroll - 2);
647643
648644   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
649   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
645   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
650646   return 0;
651647}
652648
r20931r20932
677673
678674VIDEO_START_MEMBER(m62_state,lotlot)
679675{
680   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_bg_tile_info),this), 1, 1, 12, 10, 32, 64);
681   m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_fg_tile_info),this), 1, 1, 12, 10, 32, 64);
676   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_bg_tile_info),this), 1, 1, 12, 10, 32, 64);
677   m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_lotlot_fg_tile_info),this), 1, 1, 12, 10, 32, 64);
682678}
683679
684680UINT32 m62_state::screen_update_lotlot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20931r20932
691687
692688   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
693689   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
694   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
690   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
695691   return 0;
696692}
697693
r20931r20932
740736   m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */
741737   m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */
742738
743   register_savestate(machine());
739   register_savestate();
744740
745   m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_kidniki_fg_tile_info),this), 1, 1, 12, 8, 32, 64);
741   m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_kidniki_fg_tile_info),this), 1, 1, 12, 8, 32, 64);
746742}
747743
748744UINT32 m62_state::screen_update_kidniki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20931r20932
753749   m_fg_tilemap->set_transparent_pen(0);
754750
755751   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
756   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
752   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
757753   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
758754   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
759755   return 0;
r20931r20932
791787
792788VIDEO_START_MEMBER(m62_state,spelunkr)
793789{
794   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_bg_tile_info),this), 1, 1, 8, 8, 64, 64);
795   m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32);
790   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_bg_tile_info),this), 1, 1, 8, 8, 64, 64);
791   m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32);
796792}
797793
798794UINT32 m62_state::screen_update_spelunkr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20931r20932
804800   m_fg_tilemap->set_transparent_pen(0);
805801
806802   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
807   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
803   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
808804   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
809805   return 0;
810806}
r20931r20932
833829
834830VIDEO_START_MEMBER(m62_state,spelunk2)
835831{
836   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunk2_bg_tile_info),this), 1, 1, 8, 8, 64, 64);
837   m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32);
832   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_spelunk2_bg_tile_info),this), 1, 1, 8, 8, 64, 64);
833   m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_spelunkr_fg_tile_info),this), 1, 1, 12, 8, 32, 32);
838834}
839835
840836UINT32 m62_state::screen_update_spelunk2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20931r20932
846842   m_fg_tilemap->set_transparent_pen(0);
847843
848844   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
849   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
845   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
850846   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
851847   return 0;
852848}
r20931r20932
876872
877873VIDEO_START_MEMBER(m62_state,youjyudn)
878874{
879   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_bg_tile_info),this), 1, 0, 8, 16, 64, 16);
880   m62_textlayer(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_fg_tile_info),this), 1, 1, 12, 8, 32, 32);
875   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_bg_tile_info),this), 1, 0, 8, 16, 64, 16);
876   m62_textlayer(tilemap_get_info_delegate(FUNC(m62_state::get_youjyudn_fg_tile_info),this), 1, 1, 12, 8, 32, 32);
881877   m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */
882878   m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */
883879}
r20931r20932
890886   m_fg_tilemap->set_transparent_pen(0);
891887
892888   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
893   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
889   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
894890   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
895891   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
896892   return 0;
r20931r20932
918914
919915VIDEO_START_MEMBER(m62_state,horizon)
920916{
921   m62_start(machine(), tilemap_get_info_delegate(FUNC(m62_state::get_horizon_bg_tile_info),this), 32, 0, 8, 8, 64, 32);
917   m62_start(tilemap_get_info_delegate(FUNC(m62_state::get_horizon_bg_tile_info),this), 32, 0, 8, 8, 64, 32);
922918   m_bg_tilemap->set_transmask(0, 0xffff, 0x0000); /* split type 0 is totally transparent in front half */
923919   m_bg_tilemap->set_transmask(1, 0x0001, 0xfffe); /* split type 1 has pen 0 transparent in front half */
924920}
r20931r20932
931927      m_bg_tilemap->set_scrollx(i, m_scrollram[i << 1] | (m_scrollram[(i << 1) | 1] << 8));
932928   }
933929   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
934   draw_sprites(machine(), bitmap, cliprect, 0x1f, 0x00, 0x00);
930   draw_sprites(bitmap, cliprect, 0x1f, 0x00, 0x00);
935931   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
936932   return 0;
937933}
trunk/src/mame/video/mario.c
r20931r20932
149149 * confirmed on mametests.org as being present on real PCB as well.
150150 */
151151
152static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
152void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
153153{
154154   /* TODO: draw_sprites should adopt the scanline logic from dkong.c
155155    * The schematics have the same logic for sprite buffering.
156156    */
157   mario_state *state = machine.driver_data<mario_state>();
158157   int offs;
159158
160   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
159   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
161160   {
162      if (state->m_spriteram[offs])
161      if (m_spriteram[offs])
163162      {
164163         int x, y;
165164
166165         // from schematics ....
167         y = (state->m_spriteram[offs] + (state->m_flip ? 0xF7 : 0xF9) + 1) & 0xFF;
168         x = state->m_spriteram[offs+3];
166         y = (m_spriteram[offs] + (m_flip ? 0xF7 : 0xF9) + 1) & 0xFF;
167         x = m_spriteram[offs+3];
169168         // sprite will be drawn if (y + scanline) & 0xF0 = 0xF0
170169         y = 240 - y; /* logical screen position */
171170
172         y = y ^ (state->m_flip ? 0xFF : 0x00); /* physical screen location */
173         x = x ^ (state->m_flip ? 0xFF : 0x00); /* physical screen location */
171         y = y ^ (m_flip ? 0xFF : 0x00); /* physical screen location */
172         x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */
174173
175         if (state->m_flip)
174         if (m_flip)
176175         {
177176            y -= 14;
178177            x -= 7;
179            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
180                  state->m_spriteram[offs + 2],
181                  (state->m_spriteram[offs + 1] & 0x0f) + 16 * state->m_palette_bank + 32 * state->m_monitor,
182                  !(state->m_spriteram[offs + 1] & 0x80),!(state->m_spriteram[offs + 1] & 0x40),
178            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
179                  m_spriteram[offs + 2],
180                  (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor,
181                  !(m_spriteram[offs + 1] & 0x80),!(m_spriteram[offs + 1] & 0x40),
183182                  x, y,0);
184183         }
185184         else
186185         {
187186            y += 1;
188187            x -= 8;
189            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
190                  state->m_spriteram[offs + 2],
191                  (state->m_spriteram[offs + 1] & 0x0f) + 16 * state->m_palette_bank + 32 * state->m_monitor,
192                  (state->m_spriteram[offs + 1] & 0x80),(state->m_spriteram[offs + 1] & 0x40),
188            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
189                  m_spriteram[offs + 2],
190                  (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor,
191                  (m_spriteram[offs + 1] & 0x80),(m_spriteram[offs + 1] & 0x40),
193192                  x, y,0);
194193         }
195194      }
r20931r20932
211210   m_bg_tilemap->set_scrolly(0, m_gfx_scroll - (m_flip ? 8 : 0));
212211
213212   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
214   draw_sprites(machine(), bitmap, cliprect);
213   draw_sprites(bitmap, cliprect);
215214
216215   return 0;
217216}
trunk/src/mame/video/megasys1.c
r20931r20932
194194#include "emu.h"
195195#include "includes/megasys1.h"
196196
197static void create_tilemaps(running_machine &machine);
198
199
200197#ifdef MAME_DEBUG
201198
202199#define SHOW_WRITE_ERROR(_format_,_offset_,_data_)\
r20931r20932
231228   m_buffer2_objectram = auto_alloc_array(machine(), UINT16, 0x2000);
232229   m_buffer2_spriteram16 = auto_alloc_array(machine(), UINT16, 0x2000);
233230
234   create_tilemaps(machine());
231   create_tilemaps();
235232   m_tmap[0] = m_tilemap[0][0][0];
236233   m_tmap[1] = m_tilemap[1][0][0];
237234   m_tmap[2] = m_tilemap[2][0][0];
r20931r20932
290287#define TILES_PER_PAGE_Y (0x20)
291288#define TILES_PER_PAGE (TILES_PER_PAGE_X * TILES_PER_PAGE_Y)
292289
293INLINE void scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which)
290inline void megasys1_state::scrollram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int which)
294291{
295   megasys1_state *state = space.machine().driver_data<megasys1_state>();
296   COMBINE_DATA(&state->m_scrollram[which][offset]);
297   if (offset < 0x40000/2 && state->m_tmap[which])
292   COMBINE_DATA(&m_scrollram[which][offset]);
293   if (offset < 0x40000/2 && m_tmap[which])
298294   {
299      if (state->m_scroll_flag[which] & 0x10) /* tiles are 8x8 */
295      if (m_scroll_flag[which] & 0x10) /* tiles are 8x8 */
300296      {
301         state->m_tmap[which]->mark_tile_dirty(offset );
297         m_tmap[which]->mark_tile_dirty(offset );
302298      }
303299      else
304300      {
305         state->m_tmap[which]->mark_tile_dirty(offset*4 + 0);
306         state->m_tmap[which]->mark_tile_dirty(offset*4 + 1);
307         state->m_tmap[which]->mark_tile_dirty(offset*4 + 2);
308         state->m_tmap[which]->mark_tile_dirty(offset*4 + 3);
301         m_tmap[which]->mark_tile_dirty(offset*4 + 0);
302         m_tmap[which]->mark_tile_dirty(offset*4 + 1);
303         m_tmap[which]->mark_tile_dirty(offset*4 + 2);
304         m_tmap[which]->mark_tile_dirty(offset*4 + 3);
309305      }
310306   }
311307}
312308
313WRITE16_MEMBER(megasys1_state::megasys1_scrollram_0_w){ scrollram_w(space, offset, data, mem_mask, 0); }
314WRITE16_MEMBER(megasys1_state::megasys1_scrollram_1_w){ scrollram_w(space, offset, data, mem_mask, 1); }
315WRITE16_MEMBER(megasys1_state::megasys1_scrollram_2_w){ scrollram_w(space, offset, data, mem_mask, 2); }
309WRITE16_MEMBER(megasys1_state::megasys1_scrollram_0_w){ scrollram_w(offset, data, mem_mask, 0); }
310WRITE16_MEMBER(megasys1_state::megasys1_scrollram_1_w){ scrollram_w(offset, data, mem_mask, 1); }
311WRITE16_MEMBER(megasys1_state::megasys1_scrollram_2_w){ scrollram_w(offset, data, mem_mask, 2); }
316312
317313
318314
r20931r20932
362358   SET_TILE_INFO_MEMBER(tmap, (code & 0xfff) * m_16x16_scroll_factor[tmap] + (tile_index & 3), code >> (16 - m_bits_per_color_code), 0);
363359}
364360
365static void create_tilemaps(running_machine &machine)
361void megasys1_state::create_tilemaps()
366362{
367   megasys1_state *state = machine.driver_data<megasys1_state>();
368363   int layer, i;
369364
370365   for (layer = 0; layer < 3; layer++)
371366   {
372367      /* 16x16 tilemaps */
373      state->m_tilemap[layer][0][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
368      m_tilemap[layer][0][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this),
374369                           8,8, TILES_PER_PAGE_X * 16, TILES_PER_PAGE_Y * 2);
375      state->m_tilemap[layer][0][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
370      m_tilemap[layer][0][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this),
376371                           8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 4);
377      state->m_tilemap[layer][0][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
372      m_tilemap[layer][0][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this),
378373                           8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 8);
379      state->m_tilemap[layer][0][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),state),
374      m_tilemap[layer][0][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_16x16),this),
380375                           8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 16);
381376
382377      /* 8x8 tilemaps */
383      state->m_tilemap[layer][1][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
378      m_tilemap[layer][1][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this),
384379                           8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 1);
385      state->m_tilemap[layer][1][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
380      m_tilemap[layer][1][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this),
386381                           8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
387      state->m_tilemap[layer][1][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
382      m_tilemap[layer][1][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this),
388383                           8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
389      state->m_tilemap[layer][1][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),state),
384      m_tilemap[layer][1][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(megasys1_state::megasys1_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(megasys1_state::megasys1_scan_8x8),this),
390385                           8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 4);
391386
392387      /* set user data and transparency */
393388      for (i = 0; i < 8; i++)
394389      {
395         state->m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer);
396         state->m_tilemap[layer][i/4][i%4]->set_transparent_pen(15);
390         m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer);
391         m_tilemap[layer][i/4][i%4]->set_transparent_pen(15);
397392      }
398393   }
399394}
r20931r20932
560555    0C      Y position
561556    0E      Code                                            */
562557
563static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
558void megasys1_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
564559{
565   megasys1_state *state = machine.driver_data<megasys1_state>();
566560   int color,code,sx,sy,flipx,flipy,attr,sprite,offs,color_mask;
567561
568562/* objram: 0x100*4 entries      spritedata: 0x80 entries */
569563
570564   /* sprite order is from first in Sprite Data RAM (frontmost) to last */
571565
572   if (state->m_hardware_type_z == 0)  /* standard sprite hardware */
566   if (m_hardware_type_z == 0)  /* standard sprite hardware */
573567   {
574      color_mask = (state->m_sprite_flag & 0x100) ? 0x07 : 0x0f;
568      color_mask = (m_sprite_flag & 0x100) ? 0x07 : 0x0f;
575569
576570      for (offs = (0x800-8)/2;offs >= 0;offs -= 8/2)
577571      {
578572         for (sprite = 0; sprite < 4 ; sprite ++)
579573         {
580            UINT16 *objectdata = &state->m_buffer2_objectram[offs + (0x800/2) * sprite];
581            UINT16 *spritedata = &state->m_buffer2_spriteram16[ (objectdata[ 0 ] & 0x7f) * 0x10/2];
574            UINT16 *objectdata = &m_buffer2_objectram[offs + (0x800/2) * sprite];
575            UINT16 *spritedata = &m_buffer2_spriteram16[ (objectdata[ 0 ] & 0x7f) * 0x10/2];
582576
583577            attr = spritedata[ 8/2 ];
584578            if (((attr & 0xc0)>>6) != sprite)   continue;   // flipping
r20931r20932
593587            flipx = attr & 0x40;
594588            flipy = attr & 0x80;
595589
596            if (state->m_screen_flag & 1)
590            if (m_screen_flag & 1)
597591            {
598592               flipx = !flipx;     flipy = !flipy;
599593               sx = 240-sx;        sy = 240-sy;
r20931r20932
604598            color = (attr & color_mask);
605599
606600            pdrawgfx_transpen(bitmap,cliprect,
607                  machine.gfx[3],
608                  (code & 0xfff ) + ((state->m_sprite_bank & 1) << 12),
601                  machine().gfx[3],
602                  (code & 0xfff ) + ((m_sprite_bank & 1) << 12),
609603                  color,
610604                  flipx, flipy,
611605                  sx, sy,
612                  machine.priority_bitmap,
606                  machine().priority_bitmap,
613607                  (attr & 0x08) ? 0x0c : 0x0a,15);
614608         }   /* sprite */
615609      }   /* offs */
616610   }   /* non Z hw */
617611   else
618612   {
619      UINT16 *spriteram16 = state->m_spriteram;
613      UINT16 *spriteram16 = m_spriteram;
620614
621615      /* MS1-Z just draws Sprite Data, and in reverse order */
622616
r20931r20932
638632         flipx = attr & 0x40;
639633         flipy = attr & 0x80;
640634
641         if (state->m_screen_flag & 1)
635         if (m_screen_flag & 1)
642636         {
643637            flipx = !flipx;     flipy = !flipy;
644638            sx = 240-sx;        sy = 240-sy;
645639         }
646640
647641         pdrawgfx_transpen(bitmap,cliprect,
648               machine.gfx[2],
642               machine().gfx[2],
649643               code,
650644               color,
651645               flipx, flipy,
652646               sx, sy,
653               machine.priority_bitmap,
647               machine().priority_bitmap,
654648               (attr & 0x08) ? 0x0c : 0x0a,15);
655649      }   /* sprite */
656650   }   /* Z hw */
r20931r20932
10081002   }
10091003
10101004   if (active_layers & 0x08)
1011      draw_sprites(machine(),bitmap,cliprect);
1005      draw_sprites(bitmap,cliprect);
10121006   return 0;
10131007}
10141008
trunk/src/mame/video/marineb.c
r20931r20932
150150 *
151151 *************************************/
152152
153static void set_tilemap_scrolly( running_machine &machine, int cols )
153void marineb_state::set_tilemap_scrolly( int cols )
154154{
155   marineb_state *state = machine.driver_data<marineb_state>();
156155   int col;
157156
158157   for (col = 0; col < cols; col++)
159      state->m_bg_tilemap->set_scrolly(col, state->m_column_scroll);
158      m_bg_tilemap->set_scrolly(col, m_column_scroll);
160159
161160   for (; col < 32; col++)
162      state->m_bg_tilemap->set_scrolly(col, 0);
161      m_bg_tilemap->set_scrolly(col, 0);
163162}
164163
165164
r20931r20932
167166{
168167   int offs;
169168
170   set_tilemap_scrolly(machine(), 24);
169   set_tilemap_scrolly(24);
171170   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
172171
173172   /* draw the sprites */
r20931r20932
228227{
229228   int offs, sx, sy, code, col, flipx, flipy;
230229
231   set_tilemap_scrolly(machine(), 26);
230   set_tilemap_scrolly(26);
232231   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
233232
234233   /* draw the small sprites */
r20931r20932
306305{
307306   int offs;
308307
309   set_tilemap_scrolly(machine(), 0);
308   set_tilemap_scrolly(0);
310309   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
311310
312311   /* draw the sprites */
r20931r20932
365364{
366365   int offs;
367366
368   set_tilemap_scrolly(machine(), 0);
367   set_tilemap_scrolly(0);
369368   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
370369
371370   /* draw the sprites */
r20931r20932
408407{
409408   int offs;
410409
411   set_tilemap_scrolly(machine(), 0);
410   set_tilemap_scrolly(0);
412411   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
413412
414413   /* draw the sprites */
trunk/src/mame/video/mappy.c
r20931r20932
387387
388388***************************************************************************/
389389
390static void mappy_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base)
390void mappy_state::mappy_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base)
391391{
392   mappy_state *state = machine.driver_data<mappy_state>();
393392   UINT8 *spriteram = spriteram_base + 0x780;
394393   UINT8 *spriteram_2 = spriteram + 0x800;
395394   UINT8 *spriteram_3 = spriteram_2 + 0x800;
r20931r20932
422421         sy -= 16 * sizey;
423422         sy = (sy & 0xff) - 32;  // fix wraparound
424423
425         if (state->flip_screen())
424         if (flip_screen())
426425         {
427426            flipx ^= 1;
428427            flipy ^= 1;
r20931r20932
434433         {
435434            for (x = 0;x <= sizex;x++)
436435            {
437               drawgfx_transmask(bitmap,cliprect,machine.gfx[1],
436               drawgfx_transmask(bitmap,cliprect,machine().gfx[1],
438437                  sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)],
439438                  color,
440439                  flipx,flipy,
441440                  sx + 16*x,sy + 16*y,
442                  colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 15));
441                  colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 15));
443442            }
444443         }
445444      }
r20931r20932
4684671   -------x  X position MSB
469468*/
470469
471static void phozon_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base)
470void mappy_state::phozon_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 *spriteram_base)
472471{
473   mappy_state *state = machine.driver_data<mappy_state>();
474472   UINT8 *spriteram = spriteram_base + 0x780;
475473   UINT8 *spriteram_2 = spriteram + 0x800;
476474   UINT8 *spriteram_3 = spriteram_2 + 0x800;
r20931r20932
502500         sy -= 8 * sizey;
503501         sy = (sy & 0xff) - 32;  // fix wraparound
504502
505         if (state->flip_screen())
503         if (flip_screen())
506504         {
507505            flipx ^= 1;
508506            flipy ^= 1;
r20931r20932
514512         {
515513            for (x = 0;x <= sizex;x++)
516514            {
517               drawgfx_transmask(bitmap,cliprect,machine.gfx[1],
515               drawgfx_transmask(bitmap,cliprect,machine().gfx[1],
518516                  sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)],
519517                  color,
520518                  flipx,flipy,
521519                  sx + 8*x,sy + 8*y,
522                  colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 31));
520                  colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 31));
523521            }
524522         }
525523      }
r20931r20932
535533   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES,0);
536534
537535   sprite_bitmap.fill(15, cliprect);
538   mappy_draw_sprites(machine(),sprite_bitmap,cliprect,m_spriteram);
536   mappy_draw_sprites(sprite_bitmap,cliprect,m_spriteram);
539537   copybitmap_trans(bitmap,sprite_bitmap,0,0,0,0,cliprect,15);
540538
541539   /* Redraw the high priority characters */
r20931r20932
562560
563561   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES,0);
564562
565   phozon_draw_sprites(machine(),bitmap,cliprect,m_spriteram);
563   phozon_draw_sprites(bitmap,cliprect,m_spriteram);
566564
567565   /* Redraw the high priority characters */
568566   m_bg_tilemap->draw(bitmap, cliprect, 1,0);
r20931r20932
578576
579577   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES,0);
580578
581   mappy_draw_sprites(machine(),bitmap,cliprect,m_spriteram);
579   mappy_draw_sprites(bitmap,cliprect,m_spriteram);
582580
583581   /* Redraw the high priority characters */
584582   m_bg_tilemap->draw(bitmap, cliprect, 1,0);
trunk/src/mame/video/mitchell.c
r20931r20932
270270
271271***************************************************************************/
272272
273static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
273void mitchell_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
274274{
275   mitchell_state *state = machine.driver_data<mitchell_state>();
276275   int offs, sx, sy;
277276
278277   /* the last entry is not a sprite, we skip it otherwise spang shows a bubble */
279278   /* moving diagonally across the screen */
280279   for (offs = 0x1000 - 0x40; offs >= 0; offs -= 0x20)
281280   {
282      int code = state->m_objram[offs];
283      int attr = state->m_objram[offs + 1];
281      int code = m_objram[offs];
282      int attr = m_objram[offs + 1];
284283      int color = attr & 0x0f;
285      sx = state->m_objram[offs + 3] + ((attr & 0x10) << 4);
286      sy = ((state->m_objram[offs + 2] + 8) & 0xff) - 8;
284      sx = m_objram[offs + 3] + ((attr & 0x10) << 4);
285      sy = ((m_objram[offs + 2] + 8) & 0xff) - 8;
287286      code += (attr & 0xe0) << 3;
288      if (state->m_flipscreen)
287      if (m_flipscreen)
289288      {
290289         sx = 496 - sx;
291290         sy = 240 - sy;
292291      }
293      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
292      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
294293               code,
295294               color,
296               state->m_flipscreen, state->m_flipscreen,
295               m_flipscreen, m_flipscreen,
297296               sx,sy,15);
298297   }
299298}
r20931r20932
302301{
303302   bitmap.fill(0, cliprect);
304303   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
305   draw_sprites(machine(), bitmap, cliprect);
304   draw_sprites(bitmap, cliprect);
306305   return 0;
307306}
trunk/src/mame/video/m72.c
r20931r20932
88
99***************************************************************************/
1010
11INLINE void m72_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum)
11inline void m72_state::m72_get_tile_info(tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum)
1212{
1313   int code,attr,color,pri;
1414
r20931r20932
2323   else pri = 0;
2424/* color & 0x10 is used in bchopper and hharry, more priority? */
2525
26   SET_TILE_INFO(
26   SET_TILE_INFO_MEMBER(
2727         gfxnum,
2828         code + ((attr & 0x3f) << 8),
2929         color & 0x0f,
r20931r20932
3131   tileinfo.group = pri;
3232}
3333
34INLINE void rtype2_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum)
34inline void m72_state::rtype2_get_tile_info(tile_data &tileinfo,int tile_index,const UINT16 *vram,int gfxnum)
3535{
3636   int code,attr,color,pri;
3737
r20931r20932
4848/* (vram[tile_index+2] & 0x10) is used by majtitle on the green, but it's not clear for what */
4949/* (vram[tile_index+3] & 0xfe) are used as well */
5050
51   SET_TILE_INFO(
51   SET_TILE_INFO_MEMBER(
5252         gfxnum,
5353         code,
5454         color & 0x0f,
r20931r20932
5959
6060TILE_GET_INFO_MEMBER(m72_state::m72_get_bg_tile_info)
6161{
62   m72_get_tile_info(machine(),tileinfo,tile_index,m_videoram2,2);
62   m72_get_tile_info(tileinfo,tile_index,m_videoram2,2);
6363}
6464
6565TILE_GET_INFO_MEMBER(m72_state::m72_get_fg_tile_info)
6666{
67   m72_get_tile_info(machine(),tileinfo,tile_index,m_videoram1,1);
67   m72_get_tile_info(tileinfo,tile_index,m_videoram1,1);
6868}
6969
7070TILE_GET_INFO_MEMBER(m72_state::hharry_get_bg_tile_info)
7171{
72   m72_get_tile_info(machine(),tileinfo,tile_index,m_videoram2,1);
72   m72_get_tile_info(tileinfo,tile_index,m_videoram2,1);
7373}
7474
7575TILE_GET_INFO_MEMBER(m72_state::rtype2_get_bg_tile_info)
7676{
77   rtype2_get_tile_info(machine(),tileinfo,tile_index,m_videoram2,1);
77   rtype2_get_tile_info(tileinfo,tile_index,m_videoram2,1);
7878}
7979
8080TILE_GET_INFO_MEMBER(m72_state::rtype2_get_fg_tile_info)
8181{
82   rtype2_get_tile_info(machine(),tileinfo,tile_index,m_videoram1,1);
82   rtype2_get_tile_info(tileinfo,tile_index,m_videoram1,1);
8383}
8484
8585
r20931r20932
9696
9797***************************************************************************/
9898
99static void register_savestate(running_machine &machine)
99void m72_state::register_savestate()
100100{
101   m72_state *state = machine.driver_data<m72_state>();
102   state->save_item(NAME(state->m_raster_irq_position));
103   state->save_item(NAME(state->m_video_off));
104   state->save_item(NAME(state->m_scrollx1));
105   state->save_item(NAME(state->m_scrolly1));
106   state->save_item(NAME(state->m_scrollx2));
107   state->save_item(NAME(state->m_scrolly2));
108   state->save_pointer(NAME(state->m_buffered_spriteram), state->m_spriteram.bytes()/2);
101   save_item(NAME(m_raster_irq_position));
102   save_item(NAME(m_video_off));
103   save_item(NAME(m_scrollx1));
104   save_item(NAME(m_scrolly1));
105   save_item(NAME(m_scrollx2));
106   save_item(NAME(m_scrolly2));
107   save_pointer(NAME(m_buffered_spriteram), m_spriteram.bytes()/2);
109108}
110109
111110
r20931r20932
136135   m_bg_tilemap->set_scrolldx(0,0);
137136   m_bg_tilemap->set_scrolldy(-128,-128);
138137
139   register_savestate(machine());
138   register_savestate();
140139}
141140
142141VIDEO_START_MEMBER(m72_state,xmultipl)
r20931r20932
171170   m_bg_tilemap->set_scrolldx(4,0);
172171   m_bg_tilemap->set_scrolldy(-128,16);
173172
174   register_savestate(machine());
173   register_savestate();
175174}
176175
177176VIDEO_START_MEMBER(m72_state,poundfor)
r20931r20932
221220   m_bg_tilemap->set_scrolldx(4,0);
222221   m_bg_tilemap->set_scrolldy(-128,-128);
223222
224   register_savestate(machine());
223   register_savestate();
225224}
226225
227226VIDEO_START_MEMBER(m72_state,hharry)
r20931r20932
247246   m_bg_tilemap->set_scrolldx(6,0);
248247   m_bg_tilemap->set_scrolldy(-128,16);
249248
250   register_savestate(machine());
249   register_savestate();
251250}
252251
253252
r20931r20932
273272   return m_generic_paletteram2_16[offset] | 0xffe0;   /* only D0-D4 are connected */
274273}
275274
276INLINE void changecolor(running_machine &machine,int color,int r,int g,int b)
275inline void m72_state::changecolor(int color,int r,int g,int b)
277276{
278   palette_set_color_rgb(machine,color,pal5bit(r),pal5bit(g),pal5bit(b));
277   palette_set_color_rgb(machine(),color,pal5bit(r),pal5bit(g),pal5bit(b));
279278}
280279
281280WRITE16_MEMBER(m72_state::m72_palette1_w)
r20931r20932
285284
286285   COMBINE_DATA(&m_generic_paletteram_16[offset]);
287286   offset &= 0x0ff;
288   changecolor(machine(),
289         offset,
287   changecolor(offset,
290288         m_generic_paletteram_16[offset + 0x000],
291289         m_generic_paletteram_16[offset + 0x200],
292290         m_generic_paletteram_16[offset + 0x400]);
r20931r20932
299297
300298   COMBINE_DATA(&m_generic_paletteram2_16[offset]);
301299   offset &= 0x0ff;
302   changecolor(machine(),
303         offset + 256,
300   changecolor(offset + 256,
304301         m_generic_paletteram2_16[offset + 0x000],
305302         m_generic_paletteram2_16[offset + 0x200],
306303         m_generic_paletteram2_16[offset + 0x400]);
r20931r20932
415412
416413***************************************************************************/
417414
418static void m72_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
415void m72_state::m72_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
419416{
420   m72_state *state = machine.driver_data<m72_state>();
421   UINT16 *spriteram = state->m_buffered_spriteram;
417   UINT16 *spriteram = m_buffered_spriteram;
422418   int offs;
423419
424420   offs = 0;
425   while (offs < state->m_spriteram.bytes()/2)
421   while (offs < m_spriteram.bytes()/2)
426422   {
427423      int code,color,sx,sy,flipx,flipy,w,h,x,y;
428424
r20931r20932
438434      h = 1 << ((spriteram[offs+2] & 0x3000) >> 12);
439435      sy -= 16 * h;
440436
441      if (state->flip_screen())
437      if (flip_screen())
442438      {
443439         sx = 512 - 16*w - sx;
444440         sy = 284 - 16*h - sy;
r20931r20932
457453            if (flipy) c += h-1-y;
458454            else c += y;
459455
460            drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
456            drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
461457                  c,
462458                  color,
463459                  flipx,flipy,
r20931r20932
469465   }
470466}
471467
472static void majtitle_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
468void m72_state::majtitle_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
473469{
474   m72_state *state = machine.driver_data<m72_state>();
475   UINT16 *spriteram16_2 = state->m_spriteram2;
470   UINT16 *spriteram16_2 = m_spriteram2;
476471   int offs;
477472
478   for (offs = 0;offs < state->m_spriteram.bytes();offs += 4)
473   for (offs = 0;offs < m_spriteram.bytes();offs += 4)
479474   {
480475      int code,color,sx,sy,flipx,flipy,w,h,x,y;
481476
r20931r20932
491486      h = 1 << ((spriteram16_2[offs+2] & 0x3000) >> 12);
492487      sy -= 16 * h;
493488
494      if (state->flip_screen())
489      if (flip_screen())
495490      {
496491         sx = 512 - 16*w - sx;
497492         sy = 256 - 16*h - sy;
r20931r20932
510505            if (flipy) c += h-1-y;
511506            else c += y;
512507
513            drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
508            drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
514509                  c,
515510                  color,
516511                  flipx,flipy,
r20931r20932
536531
537532   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0);
538533   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0);
539   m72_draw_sprites(machine(), bitmap,cliprect);
534   m72_draw_sprites(bitmap,cliprect);
540535   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0);
541536   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0);
542537   return 0;
r20931r20932
572567
573568   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0);
574569   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1,0);
575   majtitle_draw_sprites(machine(), bitmap,cliprect);
576   m72_draw_sprites(machine(), bitmap,cliprect);
570   majtitle_draw_sprites(bitmap,cliprect);
571   m72_draw_sprites(bitmap,cliprect);
577572   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0);
578573   m_fg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0,0);
579574   return 0;
trunk/src/mame/video/mystston.c
r20931r20932
4949{
5050   int scanline = param;
5151
52   mystston_on_scanline_interrupt(machine());
52   mystston_on_scanline_interrupt();
5353
5454   scanline = scanline + 16;
5555   if (scanline >= VTOTAL)
r20931r20932
6767 *
6868 *************************************/
6969
70static void set_palette(running_machine &machine, mystston_state *state)
70void mystston_state::set_palette()
7171{
7272   int i;
7373   static const int resistances_rg[3] = { 4700, 3300, 1500 };
7474   static const int resistances_b [2] = { 3300, 1500 };
7575   double weights_rg[3], weights_b[2];
7676
77   UINT8 *color_prom = machine.root_device().memregion("proms")->base();
77   UINT8 *color_prom = machine().root_device().memregion("proms")->base();
7878
7979   compute_resistor_weights(0, 255, -1.0,
8080         3, resistances_rg, weights_rg, 0, 4700,
r20931r20932
9191      if (i & 0x20)
9292         data = color_prom[i & 0x1f];
9393      else
94         data = state->m_paletteram[i];
94         data = m_paletteram[i];
9595
9696      /* red component */
9797      bit0 = (data >> 0) & 0x01;
r20931r20932
110110      bit1 = (data >> 7) & 0x01;
111111      b = combine_2_weights(weights_b, bit0, bit1);
112112
113      palette_set_color(machine, i, MAKE_RGB(r, g, b));
113      palette_set_color(machine(), i, MAKE_RGB(r, g, b));
114114   }
115115}
116116
r20931r20932
172172 *
173173 *************************************/
174174
175static void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, int flip)
175void mystston_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, int flip)
176176{
177   mystston_state *state = gfx->machine().driver_data<mystston_state>();
178177   int offs;
179178
180179   for (offs = 0; offs < 0x60; offs += 4)
181180   {
182      int attr = state->m_spriteram[offs];
181      int attr = m_spriteram[offs];
183182
184183      if (attr & 0x01)
185184      {
186         int code = ((attr & 0x10) << 4) | state->m_spriteram[offs + 1];
185         int code = ((attr & 0x10) << 4) | m_spriteram[offs + 1];
187186         int color = (attr & 0x08) >> 3;
188187         int flipx = attr & 0x04;
189188         int flipy = attr & 0x02;
190         int x = 240 - state->m_spriteram[offs + 3];
191         int y = (240 - state->m_spriteram[offs + 2]) & 0xff;
189         int x = 240 - m_spriteram[offs + 3];
190         int y = (240 - m_spriteram[offs + 2]) & 0xff;
192191
193192         if (flip)
194193         {
r20931r20932
247246{
248247   int flip = (*m_video_control & 0x80) ^ ((machine().root_device().ioport("DSW1")->read() & 0x20) << 2);
249248
250   set_palette(machine(), this);
249   set_palette();
251250
252251   machine().tilemap().mark_all_dirty();
253252   m_bg_tilemap->set_scrolly(0, *m_scroll);
trunk/src/mame/video/m90.c
r20931r20932
3030#include "includes/m90.h"
3131
3232
33INLINE void get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,int layer,int page_mask)
33inline void m90_state::get_tile_info(tile_data &tileinfo,int tile_index,int layer,int page_mask)
3434{
35   m90_state *state = machine.driver_data<m90_state>();
3635   int tile,color;
37   tile_index = 2*tile_index + ((state->m_video_control_data[5+layer] & page_mask) * 0x2000);
36   tile_index = 2*tile_index + ((m_video_control_data[5+layer] & page_mask) * 0x2000);
3837
39   tile=state->m_video_data[tile_index];
40   color=state->m_video_data[tile_index+1];
41   SET_TILE_INFO(
38   tile=m_video_data[tile_index];
39   color=m_video_data[tile_index+1];
40   SET_TILE_INFO_MEMBER(
4241         0,
4342         tile,
4443         color&0xf,
r20931r20932
4645         tileinfo.category = (color & 0x30) ? 1 : 0;
4746}
4847
49INLINE void bomblord_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,int layer)
48inline void m90_state::bomblord_get_tile_info(tile_data &tileinfo,int tile_index,int layer)
5049{
51   m90_state *state = machine.driver_data<m90_state>();
5250   int tile,color;
5351   tile_index = 2*tile_index + (layer * 0x2000);
5452
55   tile=state->m_video_data[tile_index];
56   color=state->m_video_data[tile_index+1];
57   SET_TILE_INFO(
53   tile=m_video_data[tile_index];
54   color=m_video_data[tile_index+1];
55   SET_TILE_INFO_MEMBER(
5856         0,
5957         tile,
6058         color&0xf,
r20931r20932
6260         tileinfo.category = (color & 0x30) ? 1 : 0;
6361}
6462
65INLINE void dynablsb_get_tile_info(running_machine &machine,tile_data &tileinfo,int tile_index,int layer)
63inline void m90_state::dynablsb_get_tile_info(tile_data &tileinfo,int tile_index,int layer)
6664{
67   m90_state *state = machine.driver_data<m90_state>();
6865   int tile,color;
6966   tile_index = 2*tile_index + (layer * 0x2000);
7067
71   tile=state->m_video_data[tile_index];
72   color=state->m_video_data[tile_index+1];
73   SET_TILE_INFO(
68   tile=m_video_data[tile_index];
69   color=m_video_data[tile_index+1];
70   SET_TILE_INFO_MEMBER(
7471         0,
7572         tile,
7673         color&0xf,
r20931r20932
7875         tileinfo.category = (color & 0x30) ? 1 : 0;
7976}
8077
81TILE_GET_INFO_MEMBER(m90_state::get_pf1_tile_info){ get_tile_info(machine(),tileinfo,tile_index,0,0x3); }
82TILE_GET_INFO_MEMBER(m90_state::get_pf1w_tile_info){ get_tile_info(machine(),tileinfo,tile_index,0,0x2); }
83TILE_GET_INFO_MEMBER(m90_state::get_pf2_tile_info){ get_tile_info(machine(),tileinfo,tile_index,1,0x3); }
84TILE_GET_INFO_MEMBER(m90_state::get_pf2w_tile_info){ get_tile_info(machine(),tileinfo,tile_index,1,0x2); }
78TILE_GET_INFO_MEMBER(m90_state::get_pf1_tile_info){ get_tile_info(tileinfo,tile_index,0,0x3); }
79TILE_GET_INFO_MEMBER(m90_state::get_pf1w_tile_info){ get_tile_info(tileinfo,tile_index,0,0x2); }
80TILE_GET_INFO_MEMBER(m90_state::get_pf2_tile_info){ get_tile_info(tileinfo,tile_index,1,0x3); }
81TILE_GET_INFO_MEMBER(m90_state::get_pf2w_tile_info){ get_tile_info(tileinfo,tile_index,1,0x2); }
8582
86TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,0); }
87TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1w_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,0); }
88TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,2); }
89TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2w_tile_info){ bomblord_get_tile_info(machine(),tileinfo,tile_index,2); }
83TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,0); }
84TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf1w_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,0); }
85TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,2); }
86TILE_GET_INFO_MEMBER(m90_state::bomblord_get_pf2w_tile_info){ bomblord_get_tile_info(tileinfo,tile_index,2); }
9087
91TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,0); }
92TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1w_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,0); }
93TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,2); }
94TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2w_tile_info){ dynablsb_get_tile_info(machine(),tileinfo,tile_index,2); }
88TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,0); }
89TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf1w_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,0); }
90TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,2); }
91TILE_GET_INFO_MEMBER(m90_state::dynablsb_get_pf2w_tile_info){ dynablsb_get_tile_info(tileinfo,tile_index,2); }
9592
9693void m90_state::video_start()
9794{
r20931r20932
136133   state_save_register_global_array(machine(), m_video_control_data);
137134}
138135
139static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
136void m90_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
140137{
141   m90_state *state = machine.driver_data<m90_state>();
142   UINT16 *spriteram = state->m_video_data + 0xee00/2;;
138   UINT16 *spriteram = m_video_data + 0xee00/2;;
143139   int offs;
144140
145141   for (offs = 0x1f2/2; offs >= 0; offs -= 3)
r20931r20932
163159
164160      for (i = 0;i < y_multi;i++)
165161
166         if (state->m_video_control_data[7] & 0x01)
167            pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
162         if (m_video_control_data[7] & 0x01)
163            pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
168164               sprite + (fy ? y_multi-1 - i : i),
169165               colour,
170166               fx,fy,
171167               x,y+i*16,
172               machine.priority_bitmap,
168               machine().priority_bitmap,
173169               (colour & 0x08) ? 0x00 : 0x02,0);
174         else if (state->m_video_control_data[7] & 0x02)
175            pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
170         else if (m_video_control_data[7] & 0x02)
171            pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
176172               sprite + (fy ? y_multi-1 - i : i),
177173               colour,
178174               fx,fy,
179175               x,y+i*16,
180               machine.priority_bitmap,
176               machine().priority_bitmap,
181177               ((colour & 0x0c)==0x0c) ? 0x00 : 0x02,0);
182178         else
183            pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
179            pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
184180               sprite + (fy ? y_multi-1 - i : i),
185181               colour,
186182               fx,fy,
187183               x,y+i*16,
188               machine.priority_bitmap,
184               machine().priority_bitmap,
189185               0x02,0);
190186   }
191187}
192188
193static void bomblord_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
189void m90_state::bomblord_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
194190{
195   m90_state *state = machine.driver_data<m90_state>();
196   UINT16 *spriteram16 = state->m_spriteram;
191   UINT16 *spriteram16 = m_spriteram;
197192   int offs = 0, last_sprite = 0;
198193   int x,y,sprite,colour,fx,fy;
199194
200195
201   while ((offs < state->m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0x8000))
196   while ((offs < m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0x8000))
202197   {
203198      last_sprite = offs;
204199      offs += 4;
r20931r20932
220215      fx = (spriteram16[offs+3] >> 8) & 0x02;
221216      fy = (spriteram16[offs+2] >> 8) & 0x80;
222217
223      pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
218      pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
224219            sprite,
225220            colour,
226221            fx,fy,
227222            x,y,
228            machine.priority_bitmap,
223            machine().priority_bitmap,
229224            (colour & 0x08) ? 0x00 : 0x02,0);
230225   }
231226}
232227
233static void dynablsb_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
228void m90_state::dynablsb_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
234229{
235   m90_state *state = machine.driver_data<m90_state>();
236   UINT16 *spriteram16 = state->m_spriteram;
230   UINT16 *spriteram16 = m_spriteram;
237231   int offs = 0, last_sprite = 0;
238232   int x,y,sprite,colour,fx,fy;
239233
240   while ((offs < state->m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0xffff))
234   while ((offs < m_spriteram.bytes()/2) & (spriteram16[offs+0] != 0xffff))
241235   {
242236      last_sprite = offs;
243237      offs += 4;
r20931r20932
259253      fx = (spriteram16[offs+3] >> 8) & 0x02;
260254      fy = (spriteram16[offs+2] >> 8) & 0x80;
261255
262      pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
256      pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
263257            sprite,
264258            colour,
265259            fx,fy,
266260            x,y,
267            machine.priority_bitmap,
261            machine().priority_bitmap,
268262            (colour & 0x08) ? 0x00 : 0x02,0);
269263   }
270264}
r20931r20932
274268   COMBINE_DATA(&m_video_control_data[offset]);
275269}
276270
277static void markdirty(tilemap_t *tmap,int page,offs_t offset)
271void m90_state::markdirty(tilemap_t *tmap,int page,offs_t offset)
278272{
279273   offset -= page * 0x2000;
280274
r20931r20932
447441         }
448442      }
449443
450      draw_sprites(machine(),bitmap,cliprect);
444      draw_sprites(bitmap,cliprect);
451445
452446   } else {
453447      bitmap.fill(get_black_pen(machine()), cliprect);
r20931r20932
503497      m_pf1_layer->draw(bitmap, cliprect, 1,1);
504498   }
505499
506   bomblord_draw_sprites(machine(),bitmap,cliprect);
500   bomblord_draw_sprites(bitmap,cliprect);
507501
508502   return 0;
509503}
r20931r20932
545539      m_pf2_layer->draw(bitmap, cliprect, 1,1);
546540   }
547541
548   dynablsb_draw_sprites(machine(),bitmap,cliprect);
542   dynablsb_draw_sprites(bitmap,cliprect);
549543
550544   return 0;
551545}
trunk/src/mame/video/mainsnk.c
r20931r20932
117117
118118
119119
120static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int scrollx, int scrolly )
120void mainsnk_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int scrollx, int scrolly )
121121{
122   mainsnk_state *state = machine.driver_data<mainsnk_state>();
123   gfx_element *gfx = machine.gfx[1];
122   gfx_element *gfx = machine().gfx[1];
124123   const UINT8 *source, *finish;
125   source =  state->m_spriteram;
124   source =  m_spriteram;
126125   finish =  source + 25*4;
127126
128127   while( source<finish )
r20931r20932
141140      sx = 288-16 - sx;
142141      sy += 8;
143142
144      if (state->flip_screen())
143      if (flip_screen())
145144      {
146145         sx = 288-16 - sx;
147146         sy = 224-16 - sy;
r20931r20932
163162UINT32 mainsnk_state::screen_update_mainsnk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
164163{
165164   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
166   draw_sprites(machine(), bitmap, cliprect, 0, 0);
165   draw_sprites(bitmap, cliprect, 0, 0);
167166   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
168167
169168   return 0;
trunk/src/mame/video/m57.c
r20931r20932
170170 *
171171 *************************************/
172172
173static void draw_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
173void m57_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
174174{
175   m57_state *state = machine.driver_data<m57_state>();
176175   int y,x;
177176   INT16 scrolly;
178177
179178   // from 64 to 127: not wrapped
180179   for (y = 64; y < 128; y++)
181      state->m_bg_tilemap->set_scrollx(y, state->m_scrollram[0x40]);
180      m_bg_tilemap->set_scrollx(y, m_scrollram[0x40]);
182181
183   state->m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
182   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
184183
185184   // from 128 to 255: wrapped
186185   for (y = 128; y <= cliprect.max_y; y++)
187186   {
188      scrolly = state->m_scrollram[y] + (state->m_scrollram[y + 0x100] << 8);
187      scrolly = m_scrollram[y] + (m_scrollram[y + 0x100] << 8);
189188
190189      if (scrolly >= 0)
191190      {
r20931r20932
214213 *
215214 *************************************/
216215
217static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
216void m57_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
218217{
219   m57_state *state = machine.driver_data<m57_state>();
220218   int offs;
221219
222   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
220   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
223221   {
224      UINT8 attributes = state->m_spriteram[offs + 1];
225      int sx = state->m_spriteram[offs + 3];
226      int sy = ((224 - state->m_spriteram[offs + 0] - 32) & 0xff) + 32;
227      int code = state->m_spriteram[offs + 2];
222      UINT8 attributes = m_spriteram[offs + 1];
223      int sx = m_spriteram[offs + 3];
224      int sy = ((224 - m_spriteram[offs + 0] - 32) & 0xff) + 32;
225      int code = m_spriteram[offs + 2];
228226      int color = attributes & 0x1f;
229227      int flipy = attributes & 0x80;
230228      int flipx = attributes & 0x40;
r20931r20932
235233      if (code & 0x80) bank += 1;
236234      if (attributes & 0x20) bank += 2;
237235
238      if (state->m_flipscreen)
236      if (m_flipscreen)
239237      {
240238         sx = 240 - sx;
241239         sy = 224 - sy;
r20931r20932
243241         flipy = !flipy;
244242      }
245243
246      drawgfx_transmask(bitmap, cliprect, machine.gfx[1 + bank],
244      drawgfx_transmask(bitmap, cliprect, machine().gfx[1 + bank],
247245         tile_number,
248246         color,
249247         flipx, flipy,
250248         sx, sy,
251         colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 256 + 15));
249         colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 256 + 15));
252250   }
253251}
254252
r20931r20932
262260
263261UINT32 m57_state::screen_update_m57(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
264262{
265   draw_background(machine(), bitmap, cliprect);
266   draw_sprites(machine(), bitmap, cliprect);
263   draw_background(bitmap, cliprect);
264   draw_sprites(bitmap, cliprect);
267265   return 0;
268266}
trunk/src/mame/video/m107.c
r20931r20932
146146
147147/*****************************************************************************/
148148
149static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
149void m107_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
150150{
151   m107_state *state = machine.driver_data<m107_state>();
152   UINT16 *spriteram = state->m_buffered_spriteram;
151   UINT16 *spriteram = m_buffered_spriteram;
153152   int offs;
154   UINT8 *rom = state->memregion("user1")->base();
153   UINT8 *rom = memregion("user1")->base();
155154
156155   for (offs = 0;offs < 0x800;offs += 4)
157156   {
r20931r20932
176175      fy=(spriteram[offs+2]>>8)&0x2;
177176      y_multi=(spriteram[offs+0]>>11)&0x3;
178177
179      if (state->m_spritesystem == 0)
178      if (m_spritesystem == 0)
180179      {
181180         y_multi=1 << y_multi; /* 1, 2, 4 or 8 */
182181
r20931r20932
185184
186185         for (i=0; i<y_multi; i++)
187186         {
188            pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
187            pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
189188                  sprite + s_ptr,
190189                  colour,
191190                  fx,fy,
192191                  x,y-i*16,
193                  machine.priority_bitmap,pri_mask,0);
192                  machine().priority_bitmap,pri_mask,0);
194193
195194            /* wrap-around y */
196            pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
195            pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
197196                  sprite + s_ptr,
198197                  colour,
199198                  fx,fy,
200199                  x,(y-i*16) - 0x200,
201                  machine.priority_bitmap,pri_mask,0);
200                  machine().priority_bitmap,pri_mask,0);
202201
203202            if (fy) s_ptr++; else s_ptr--;
204203         }
r20931r20932
242241               if (!ffy) sprite+=y_multi-1;
243242               for (i=0; i<y_multi; i++)
244243               {
245                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
244                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
246245                        sprite+(ffy?i:-i),
247246                        colour,
248247                        ffx,ffy,
249248                        (x+xdisp)&0x1ff,(y-ydisp-16*i)&0x1ff,
250                        machine.priority_bitmap,pri_mask,0);
249                        machine().priority_bitmap,pri_mask,0);
251250
252251                  /* wrap-around y */
253                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
252                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
254253                        sprite+(ffy?i:-i),
255254                        colour,
256255                        ffx,ffy,
257256                        (x+xdisp)&0x1ff,((y-ydisp-16*i)&0x1ff)-0x200,
258                        machine.priority_bitmap,pri_mask,0);
257                        machine().priority_bitmap,pri_mask,0);
259258               }
260259
261260               if (rom[rom_offs+1]&0x80) break;    /* end of block */
r20931r20932
269268
270269/*****************************************************************************/
271270
272static void m107_update_scroll_positions(running_machine &machine)
271void m107_state::m107_update_scroll_positions()
273272{
274   m107_state *state = machine.driver_data<m107_state>();
275273   int laynum;
276274   int i;
277275
r20931r20932
283281
284282   for (laynum = 0; laynum < 4; laynum++)
285283   {
286      pf_layer_info *layer = &state->m_pf_layer[laynum];
284      pf_layer_info *layer = &m_pf_layer[laynum];
287285
288      int scrolly = state->m_control[0 + 2 * laynum];
289      int scrollx = state->m_control[1 + 2 * laynum];
286      int scrolly = m_control[0 + 2 * laynum];
287      int scrollx = m_control[1 + 2 * laynum];
290288
291      if (state->m_control[0x08 + laynum] & 0x01) //used by World PK Soccer goal scrolling and Fire Barrel sea wave effect (stage 2) / canyon parallax effect (stage 6)
289      if (m_control[0x08 + laynum] & 0x01) //used by World PK Soccer goal scrolling and Fire Barrel sea wave effect (stage 2) / canyon parallax effect (stage 6)
292290      {
293         const UINT16 *scrolldata = state->m_vram_data + (0xe000 + 0x200 * laynum) / 2;
291         const UINT16 *scrolldata = m_vram_data + (0xe000 + 0x200 * laynum) / 2;
294292
295293         layer->tmap->set_scroll_rows(512);
296294         for (i = 0; i < 512; i++)
r20931r20932
309307
310308/*****************************************************************************/
311309
312static void m107_tilemap_draw(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int laynum, int category,int opaque)
310void m107_state::m107_tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int laynum, int category,int opaque)
313311{
314   m107_state *state = machine.driver_data<m107_state>();
315312   int line;
316313   rectangle clip;
317   const rectangle &visarea = machine.primary_screen->visible_area();
314   const rectangle &visarea = machine().primary_screen->visible_area();
318315   clip = visarea;
319316
320   if (state->m_control[0x08 + laynum] & 0x02)
317   if (m_control[0x08 + laynum] & 0x02)
321318   {
322319      for (line = cliprect.min_y; line <= cliprect.max_y;line++)
323320      {
324         const UINT16 *scrolldata = state->m_vram_data + (0xe800 + 0x200 * laynum) / 2;
321         const UINT16 *scrolldata = m_vram_data + (0xe800 + 0x200 * laynum) / 2;
325322         clip.min_y = clip.max_y = line;
326323
327         state->m_pf_layer[laynum].tmap->set_scrollx(0,  state->m_control[1 + 2 * laynum]);
328         state->m_pf_layer[laynum].tmap->set_scrolly(0,  (state->m_control[0 + 2 * laynum] + scrolldata[line]));
324         m_pf_layer[laynum].tmap->set_scrollx(0,  m_control[1 + 2 * laynum]);
325         m_pf_layer[laynum].tmap->set_scrolly(0,  (m_control[0 + 2 * laynum] + scrolldata[line]));
329326
330         state->m_pf_layer[laynum].tmap->draw(bitmap, clip, category | opaque, category);
327         m_pf_layer[laynum].tmap->draw(bitmap, clip, category | opaque, category);
331328      }
332329   }
333330   else
334      state->m_pf_layer[laynum].tmap->draw(bitmap, cliprect, category | opaque, category);
331      m_pf_layer[laynum].tmap->draw(bitmap, cliprect, category | opaque, category);
335332}
336333
337334
338static void m107_screenrefresh(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
335void m107_state::m107_screenrefresh(bitmap_ind16 &bitmap, const rectangle &cliprect)
339336{
340   m107_state *state = machine.driver_data<m107_state>();
341   machine.priority_bitmap.fill(0, cliprect);
337   machine().priority_bitmap.fill(0, cliprect);
342338
343   if ((~state->m_control[0x0b] >> 7) & 1)
339   if ((~m_control[0x0b] >> 7) & 1)
344340   {
345      m107_tilemap_draw(machine, bitmap, cliprect, 3, 0,0);
346      m107_tilemap_draw(machine, bitmap, cliprect, 3, 1,0);
341      m107_tilemap_draw(bitmap, cliprect, 3, 0,0);
342      m107_tilemap_draw(bitmap, cliprect, 3, 1,0);
347343   }
348344   else
349345      bitmap.fill(0, cliprect);
350346
351347   /* note: the opaque flag is used if layer 3 is disabled, noticeable in World PK Soccer title and gameplay screens */
352   m107_tilemap_draw(machine, bitmap, cliprect, 2, 0,(((state->m_control[0x0b] >> 7) & 1) ? TILEMAP_DRAW_OPAQUE : 0));
353   m107_tilemap_draw(machine, bitmap, cliprect, 1, 0,0);
354   m107_tilemap_draw(machine, bitmap, cliprect, 0, 0,0);
355   m107_tilemap_draw(machine, bitmap, cliprect, 2, 1,0);
356   m107_tilemap_draw(machine, bitmap, cliprect, 1, 1,0);
357   m107_tilemap_draw(machine, bitmap, cliprect, 0, 1,0);
348   m107_tilemap_draw(bitmap, cliprect, 2, 0,(((m_control[0x0b] >> 7) & 1) ? TILEMAP_DRAW_OPAQUE : 0));
349   m107_tilemap_draw(bitmap, cliprect, 1, 0,0);
350   m107_tilemap_draw(bitmap, cliprect, 0, 0,0);
351   m107_tilemap_draw(bitmap, cliprect, 2, 1,0);
352   m107_tilemap_draw(bitmap, cliprect, 1, 1,0);
353   m107_tilemap_draw(bitmap, cliprect, 0, 1,0);
358354
359   if(state->m_sprite_display)
360      draw_sprites(machine, bitmap, cliprect);
355   if(m_sprite_display)
356      draw_sprites(bitmap, cliprect);
361357
362358   /* This hardware probably has more priority values - but I haven't found
363359       any used yet */
r20931r20932
382378
383379UINT32 m107_state::screen_update_m107(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
384380{
385   m107_update_scroll_positions(machine());
386   m107_screenrefresh(machine(), bitmap, cliprect);
381   m107_update_scroll_positions();
382   m107_screenrefresh(bitmap, cliprect);
387383   return 0;
388384}
trunk/src/mame/video/m92.c
r20931r20932
4848{
4949   m_sprite_buffer_busy = 1;
5050   if (m_game_kludge!=2) /* Major Title 2 doesn't like this interrupt!? */
51      m92_sprite_interrupt(machine());
51      m92_sprite_interrupt();
5252}
5353
5454WRITE16_MEMBER(m92_state::m92_spritecontrol_w)
r20931r20932
308308
309309/*****************************************************************************/
310310
311static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
311void m92_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
312312{
313   m92_state *state = machine.driver_data<m92_state>();
314   UINT16 *source = state->m_spriteram->buffer();
313   UINT16 *source = m_spriteram->buffer();
315314   int offs, layer;
316315
317316   for (layer = 0; layer < 8; layer++)
318317   {
319      for (offs = 0; offs < state->m_sprite_list; )
318      for (offs = 0; offs < m_sprite_list; )
320319      {
321320         int x = source[offs+3] & 0x1ff;
322321         int y = source[offs+0] & 0x1ff;
r20931r20932
345344
346345            for (row = 0; row < numrows; row++)
347346            {
348               if (state->flip_screen())
347               if (flip_screen())
349348               {
350                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
349                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
351350                        code + s_ptr, color, !flipx, !flipy,
352351                        464 - x, 240 - (y - row * 16),
353                        machine.priority_bitmap, pri, 0);
352                        machine().priority_bitmap, pri, 0);
354353
355354                  // wrap around x
356                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
355                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
357356                        code + s_ptr, color, !flipx, !flipy,
358357                        464 - x + 512, 240 - (y - row * 16),
359                        machine.priority_bitmap, pri, 0);
358                        machine().priority_bitmap, pri, 0);
360359               }
361360               else
362361               {
363                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
362                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
364363                        code + s_ptr, color, flipx, flipy,
365364                        x, y - row * 16,
366                        machine.priority_bitmap, pri, 0);
365                        machine().priority_bitmap, pri, 0);
367366
368367                  // wrap around x
369                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
368                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
370369                        code + s_ptr, color, flipx, flipy,
371370                        x - 512, y - row * 16,
372                        machine.priority_bitmap, pri, 0);
371                        machine().priority_bitmap, pri, 0);
373372               }
374373               if (flipy) s_ptr++;
375374               else s_ptr--;
r20931r20932
382381}
383382
384383// This needs a lot of work...
385static void ppan_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
384void m92_state::ppan_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
386385{
387   m92_state *state = machine.driver_data<m92_state>();
388   UINT16 *source = state->m_spriteram->live(); // sprite buffer control is never triggered
386   UINT16 *source = m_spriteram->live(); // sprite buffer control is never triggered
389387   int offs, layer;
390388
391389   for (layer = 0; layer < 8; layer++)
392390   {
393      for (offs = 0; offs < state->m_sprite_list; )
391      for (offs = 0; offs < m_sprite_list; )
394392      {
395393         int x = source[offs+3] & 0x1ff;
396394         int y = source[offs+0] & 0x1ff;
r20931r20932
420418
421419            for (row = 0; row < numrows; row++)
422420            {
423               if (state->flip_screen())
421               if (flip_screen())
424422               {
425                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
423                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
426424                        code + s_ptr, color, !flipx, !flipy,
427425                        464 - x, 240 - (y - row * 16),
428                        machine.priority_bitmap, pri, 0);
426                        machine().priority_bitmap, pri, 0);
429427
430428                  // wrap around x
431                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
429                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
432430                        code + s_ptr, color, !flipx, !flipy,
433431                        464 - x + 512, 240 - (y - row * 16),
434                        machine.priority_bitmap, pri, 0);
432                        machine().priority_bitmap, pri, 0);
435433               }
436434               else
437435               {
438                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
436                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
439437                        code + s_ptr, color, flipx, flipy,
440438                        x, y - row * 16,
441                        machine.priority_bitmap, pri, 0);
439                        machine().priority_bitmap, pri, 0);
442440
443441                  // wrap around x
444                  pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
442                  pdrawgfx_transpen(bitmap,cliprect,machine().gfx[1],
445443                        code + s_ptr, color, flipx, flipy,
446444                        x - 512, y - row * 16,
447                        machine.priority_bitmap, pri, 0);
445                        machine().priority_bitmap, pri, 0);
448446               }
449447               if (flipy) s_ptr++;
450448               else s_ptr--;
r20931r20932
458456
459457/*****************************************************************************/
460458
461static void m92_update_scroll_positions(running_machine &machine)
459void m92_state::m92_update_scroll_positions()
462460{
463   m92_state *state = machine.driver_data<m92_state>();
464461   int laynum;
465462   int i;
466463
r20931r20932
477474
478475   for (laynum = 0; laynum < 3; laynum++)
479476   {
480      pf_layer_info *layer = &state->m_pf_layer[laynum];
477      pf_layer_info *layer = &m_pf_layer[laynum];
481478
482      if (state->m_pf_master_control[laynum] & 0x40)
479      if (m_pf_master_control[laynum] & 0x40)
483480      {
484         const UINT16 *scrolldata = state->m_vram_data + (0xf400 + 0x400 * laynum) / 2;
481         const UINT16 *scrolldata = m_vram_data + (0xf400 + 0x400 * laynum) / 2;
485482
486483         layer->tmap->set_scroll_rows(512);
487484         layer->wide_tmap->set_scroll_rows(512);
r20931r20932
506503
507504/*****************************************************************************/
508505
509static void m92_draw_tiles(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
506void m92_state::m92_draw_tiles(bitmap_ind16 &bitmap,const rectangle &cliprect)
510507{
511   m92_state *state = machine.driver_data<m92_state>();
512508
513   if ((~state->m_pf_master_control[2] >> 4) & 1)
509   if ((~m_pf_master_control[2] >> 4) & 1)
514510   {
515      state->m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
516      state->m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
517      state->m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
518      state->m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
511      m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
512      m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
513      m_pf_layer[2].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
514      m_pf_layer[2].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
519515   }
520516
521   state->m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
522   state->m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
523   state->m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
524   state->m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
517   m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
518   m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
519   m_pf_layer[1].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
520   m_pf_layer[1].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
525521
526   state->m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
527   state->m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
528   state->m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
529   state->m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
522   m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
523   m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
524   m_pf_layer[0].wide_tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
525   m_pf_layer[0].tmap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
530526}
531527
532528
r20931r20932
534530{
535531   machine().priority_bitmap.fill(0, cliprect);
536532   bitmap.fill(0, cliprect);
537   m92_update_scroll_positions(machine());
538   m92_draw_tiles(machine(), bitmap, cliprect);
533   m92_update_scroll_positions();
534   m92_draw_tiles(bitmap, cliprect);
539535
540   draw_sprites(machine(), bitmap, cliprect);
536   draw_sprites(bitmap, cliprect);
541537
542538   /* Flipscreen appears hardwired to the dipswitch - strange */
543539   if (machine().root_device().ioport("DSW")->read() & 0x100)
r20931r20932
551547{
552548   machine().priority_bitmap.fill(0, cliprect);
553549   bitmap.fill(0, cliprect);
554   m92_update_scroll_positions(machine());
555   m92_draw_tiles(machine(), bitmap, cliprect);
550   m92_update_scroll_positions();
551   m92_draw_tiles(bitmap, cliprect);
556552
557   ppan_draw_sprites(machine(), bitmap, cliprect);
553   ppan_draw_sprites(bitmap, cliprect);
558554
559555   /* Flipscreen appears hardwired to the dipswitch - strange */
560556   if (machine().root_device().ioport("DSW")->read() & 0x100)
trunk/src/mame/video/m58.c
r20931r20932
209209 *
210210 *************************************/
211211
212#define DRAW_SPRITE(code, sy) drawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, sx, sy, colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 512));
212#define DRAW_SPRITE(code, sy) drawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, sx, sy, colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 512));
213213
214static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
214void m58_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
215215{
216   m58_state *state = machine.driver_data<m58_state>();
217216   int offs;
218   const rectangle &visarea = machine.primary_screen->visible_area();
217   const rectangle &visarea = machine().primary_screen->visible_area();
219218
220   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
219   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
221220   {
222      int attr = state->m_spriteram[offs + 1];
221      int attr = m_spriteram[offs + 1];
223222      int bank = (attr & 0x20) >> 5;
224      int code1 = state->m_spriteram[offs + 2] & 0xbf;
223      int code1 = m_spriteram[offs + 2] & 0xbf;
225224      int code2 = 0;
226225      int color = attr & 0x1f;
227226      int flipx = attr & 0x40;
228227      int flipy = attr & 0x80;
229      int sx = state->m_spriteram[offs + 3];
230      int sy1 = 233 - state->m_spriteram[offs];
228      int sx = m_spriteram[offs + 3];
229      int sy1 = 233 - m_spriteram[offs];
231230      int sy2 = 0;
232231
233232      if (flipy)
r20931r20932
240239         code2 = code1 + 0x40;
241240      }
242241
243      if (state->flip_screen())
242      if (flip_screen())
244243      {
245244         sx = 240 - sx;
246245         sy2 = 192 - sy1;
r20931r20932
266265 *
267266 *************************************/
268267
269static void draw_panel( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
268void m58_state::draw_panel( bitmap_ind16 &bitmap, const rectangle &cliprect )
270269{
271   m58_state *state = machine.driver_data<m58_state>();
272270
273   if (!*state->m_yard_score_panel_disabled)
271   if (!*m_yard_score_panel_disabled)
274272   {
275273      const rectangle clippanel(26*8, 32*8-1, 1*8, 31*8-1);
276274      const rectangle clippanelflip(0*8, 6*8-1, 1*8, 31*8-1);
277      rectangle clip = state->flip_screen() ? clippanelflip : clippanel;
278      const rectangle &visarea = machine.primary_screen->visible_area();
279      int sx = state->flip_screen() ? cliprect.min_x - 8 : cliprect.max_x + 1 - SCROLL_PANEL_WIDTH;
280      int yoffs = state->flip_screen() ? -40 : -16;
275      rectangle clip = flip_screen() ? clippanelflip : clippanel;
276      const rectangle &visarea = machine().primary_screen->visible_area();
277      int sx = flip_screen() ? cliprect.min_x - 8 : cliprect.max_x + 1 - SCROLL_PANEL_WIDTH;
278      int yoffs = flip_screen() ? -40 : -16;
281279
282280      clip.min_y += visarea.min_y + yoffs;
283281      clip.max_y += visarea.max_y + yoffs;
284282      clip &= cliprect;
285283
286      copybitmap(bitmap, *state->m_scroll_panel_bitmap, state->flip_screen(), state->flip_screen(),
284      copybitmap(bitmap, *m_scroll_panel_bitmap, flip_screen(), flip_screen(),
287285               sx, visarea.min_y + yoffs, clip);
288286   }
289287}
r20931r20932
302300   m_bg_tilemap->set_scrolly(0, *m_yard_scroll_y_low);
303301
304302   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
305   draw_sprites(machine(), bitmap, cliprect);
306   draw_panel(machine(), bitmap, cliprect);
303   draw_sprites(bitmap, cliprect);
304   draw_panel(bitmap, cliprect);
307305   return 0;
308306}
trunk/src/mame/video/metlclsh.c
r20931r20932
163163
164164***************************************************************************/
165165
166static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
166void metlclsh_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
167167{
168   metlclsh_state *state = machine.driver_data<metlclsh_state>();
169   UINT8 *spriteram = state->m_spriteram;
170   gfx_element *gfx = machine.gfx[0];
168   UINT8 *spriteram = m_spriteram;
169   gfx_element *gfx = machine().gfx[0];
171170   int offs;
172171
173   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
172   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
174173   {
175174      int attr, code, color, sx, sy, flipx, flipy, wrapy, sizey;
176175
r20931r20932
190189
191190      sy = 240 - spriteram[offs + 2];
192191
193      if (state->flip_screen())
192      if (flip_screen())
194193      {
195194         sx = 240 - sx;  flipx = !flipx;
196195         sy = 240 - sy;  flipy = !flipy;     if (sizey)  sy += 16;
r20931r20932
244243      m_bg_tilemap->set_scrollx(0, m_scrollx[1] + ((m_scrollx[0] & 0x02) << 7) );
245244      m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
246245   }
247   draw_sprites(machine(), bitmap, cliprect);          // sprites
246   draw_sprites(bitmap, cliprect);          // sprites
248247   m_fg_tilemap->draw(bitmap, cliprect, 2, 0); // high priority tiles of foreground
249248
250249//  popmessage("%02X", m_scrollx[0]);
trunk/src/mame/video/mcr.c
r20931r20932
130130 *
131131 *************************************/
132132
133static void mcr_set_color(running_machine &machine, int index, int data)
133void mcr_state::mcr_set_color(int index, int data)
134134{
135   palette_set_color_rgb(machine, index, pal3bit(data >> 6), pal3bit(data >> 0), pal3bit(data >> 3));
135   palette_set_color_rgb(machine(), index, pal3bit(data >> 6), pal3bit(data >> 0), pal3bit(data >> 3));
136136}
137137
138138
139static void journey_set_color(running_machine &machine, int index, int data)
139void mcr_state::journey_set_color(int index, int data)
140140{
141141   /* 3 bits each, RGB */
142142   int r = (data >> 6) & 7;
r20931r20932
149149   b = (b << 5) | (b << 1);
150150
151151   /* set the BG color */
152   palette_set_color(machine, index, MAKE_RGB(r, g, b));
152   palette_set_color(machine(), index, MAKE_RGB(r, g, b));
153153
154154   /* if this is an odd entry in the upper palette bank, the hardware */
155155   /* hard-codes a low 1 bit -- this is used for better grayscales */
r20931r20932
161161   }
162162
163163   /* set the FG color */
164   palette_set_color(machine, index + 64, MAKE_RGB(r, g, b));
164   palette_set_color(machine(), index + 64, MAKE_RGB(r, g, b));
165165}
166166
167167
r20931r20932
169169{
170170   m_generic_paletteram_8[offset] = data;
171171   offset &= 0x7f;
172   mcr_set_color(machine(), (offset / 2) & 0x3f, data | ((offset & 1) << 8));
172   mcr_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8));
173173}
174174
175175
r20931r20932
198198   if ((offset & 0x780) == 0x780)
199199   {
200200      if (mcr_cpu_board != 91475)
201         mcr_set_color(machine(), (offset / 2) & 0x3f, data | ((offset & 1) << 8));
201         mcr_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8));
202202      else
203         journey_set_color(machine(), (offset / 2) & 0x3f, data | ((offset & 1) << 8));
203         journey_set_color((offset / 2) & 0x3f, data | ((offset & 1) << 8));
204204   }
205205}
206206
r20931r20932
224224
225225   /* palette RAM is mapped into the upper 0x80 bytes here */
226226   if ((effoffs & 0x780) == 0x780)
227      mcr_set_color(machine(), ((offset & 0x400) >> 5) | ((offset >> 1) & 0x1f), data | ((offset & 1) << 8));
227      mcr_set_color(((offset & 0x400) >> 5) | ((offset >> 1) & 0x1f), data | ((offset & 1) << 8));
228228}
229229
230230
r20931r20932
247247 *
248248 *************************************/
249249
250static void render_sprites_91399(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
250void mcr_state::render_sprites_91399(bitmap_ind16 &bitmap, const rectangle &cliprect)
251251{
252   mcr_state *state = machine.driver_data<mcr_state>();
253   UINT8 *spriteram = state->m_spriteram;
254   gfx_element *gfx = machine.gfx[1];
252   UINT8 *spriteram = m_spriteram;
253   gfx_element *gfx = machine().gfx[1];
255254   int offs;
256255
257256   /* render the sprites into the bitmap, ORing together */
258   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
257   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
259258   {
260259      int code, x, y, sx, sy, hflip, vflip;
261260
r20931r20932
287286         {
288287            const UINT8 *src = gfx->get_data(code) + gfx->rowbytes() * (y ^ vflip);
289288            UINT16 *dst = &bitmap.pix16(sy);
290            UINT8 *pri = &machine.priority_bitmap.pix8(sy);
289            UINT8 *pri = &machine().priority_bitmap.pix8(sy);
291290
292291            /* loop over columns */
293292            for (x = 0; x < 32; x++)
r20931r20932
320319 *
321320 *************************************/
322321
323static void render_sprites_91464(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int sprmask, int colormask)
322void mcr_state::render_sprites_91464(bitmap_ind16 &bitmap, const rectangle &cliprect, int primask, int sprmask, int colormask)
324323{
325   mcr_state *state = machine.driver_data<mcr_state>();
326   UINT8 *spriteram = state->m_spriteram;
327   gfx_element *gfx = machine.gfx[1];
324   UINT8 *spriteram = m_spriteram;
325   gfx_element *gfx = machine().gfx[1];
328326   int offs;
329327
330328   /* render the sprites into the bitmap, working from topmost to bottommost */
331   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
329   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
332330   {
333331      int code, color, x, y, sx, sy, hflip, vflip;
334332
r20931r20932
359357         {
360358            const UINT8 *src = gfx->get_data(code) + gfx->rowbytes() * (y ^ vflip);
361359            UINT16 *dst = &bitmap.pix16(sy);
362            UINT8 *pri = &machine.priority_bitmap.pix8(sy);
360            UINT8 *pri = &machine().priority_bitmap.pix8(sy);
363361
364362            /* loop over columns */
365363            for (x = 0; x < 32; x++)
r20931r20932
411409   switch (mcr_sprite_board)
412410   {
413411      case 91399:
414         render_sprites_91399(machine(), bitmap, cliprect);
412         render_sprites_91399(bitmap, cliprect);
415413         break;
416414
417415      case 91464:
418416         if (mcr_cpu_board == 91442)
419            render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x00);
417            render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00);
420418         else if (mcr_cpu_board == 91475)
421            render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x40);
419            render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x40);
422420         else if (mcr_cpu_board == 91490)
423            render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x00);
421            render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00);
424422         else if (mcr_cpu_board == 91721)
425            render_sprites_91464(machine(), bitmap, cliprect, 0x00, 0x30, 0x00);
423            render_sprites_91464(bitmap, cliprect, 0x00, 0x30, 0x00);
426424         break;
427425   }
428426   return 0;
trunk/src/mame/video/m10.c
r20931r20932
8484}
8585
8686
87INLINE void plot_pixel_m10( running_machine &machine, bitmap_ind16 &bm, int x, int y, int col )
87inline void m10_state::plot_pixel_m10( bitmap_ind16 &bm, int x, int y, int col )
8888{
89   m10_state *state = machine.driver_data<m10_state>();
9089
91   if (!state->m_flip)
90   if (!m_flip)
9291      bm.pix16(y, x) = col;
9392   else
9493      bm.pix16((IREMM10_VBSTART - 1) - (y - IREMM10_VBEND) + 6,
r20931r20932
145144      int y;
146145
147146      for (y = IREMM10_VBEND; y < IREMM10_VBSTART; y++)
148         plot_pixel_m10(machine(), bitmap, 16, y, 1);
147         plot_pixel_m10(bitmap, 16, y, 1);
149148   }
150149
151150   for (offs = m_videoram.bytes() - 1; offs >= 0; offs--)
trunk/src/mame/video/mermaid.c
r20931r20932
178178   machine().primary_screen->register_screen_bitmap(m_helper2);
179179}
180180
181static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
181void mermaid_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
182182{
183183   const rectangle spritevisiblearea(0 * 8, 26 * 8 - 1, 2 * 8, 30 * 8 - 1);
184184   const rectangle flip_spritevisiblearea(6 * 8, 31 * 8 - 1, 2 * 8, 30 * 8 - 1);
185185
186   mermaid_state *state = machine.driver_data<mermaid_state>();
187   UINT8 *spriteram = state->m_spriteram;
186   UINT8 *spriteram = m_spriteram;
188187   int offs;
189188
190   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
189   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
191190   {
192191      int attr = spriteram[offs + 2];
193192      int bank = (attr & 0x30) >> 4;
r20931r20932
200199
201200      if (sx >= 0xf0) sx -= 256;
202201
203      code |= state->m_rougien_gfxbank1 * 0x2800;
204      code |= state->m_rougien_gfxbank2 * 0x2400;
202      code |= m_rougien_gfxbank1 * 0x2800;
203      code |= m_rougien_gfxbank2 * 0x2400;
205204
206      if (state->flip_screen_x())
205      if (flip_screen_x())
207206      {
208207         flipx = !flipx;
209208         sx = 240 - sx;
210209      }
211210
212      if (state->flip_screen_y())
211      if (flip_screen_y())
213212      {
214213         flipy = !flipy;
215214         sy = 240 - sy;
216215      }
217216
218      drawgfx_transpen(bitmap, (state->flip_screen_x() ? flip_spritevisiblearea : spritevisiblearea),
219         machine.gfx[1], code, color, flipx, flipy, sx, sy, 0);
217      drawgfx_transpen(bitmap, (flip_screen_x() ? flip_spritevisiblearea : spritevisiblearea),
218         machine().gfx[1], code, color, flipx, flipy, sx, sy, 0);
220219   }
221220}
222221
r20931r20932
224223{
225224   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
226225   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
227   draw_sprites(machine(), bitmap, cliprect);
226   draw_sprites(bitmap, cliprect);
228227   return 0;
229228}
230229
231static UINT8 collision_check( running_machine &machine, rectangle& rect )
230UINT8 mermaid_state::collision_check( rectangle& rect )
232231{
233   mermaid_state *state = machine.driver_data<mermaid_state>();
234232   UINT8 data = 0;
235233
236234   int x;
r20931r20932
239237   for (y = rect.min_y; y <= rect.max_y; y++)
240238      for (x = rect.min_x; x <= rect.max_x; x++)
241239      {
242         UINT16 a = colortable_entry_get_value(machine.colortable, state->m_helper.pix16(y, x)) & 0x3f;
243         UINT16 b = colortable_entry_get_value(machine.colortable, state->m_helper2.pix16(y, x)) & 0x3f;
240         UINT16 a = colortable_entry_get_value(machine().colortable, m_helper.pix16(y, x)) & 0x3f;
241         UINT16 b = colortable_entry_get_value(machine().colortable, m_helper2.pix16(y, x)) & 0x3f;
244242
245243         if (b)
246244            if (a)
r20931r20932
314312
315313         drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0);
316314
317         m_coll_bit2 |= collision_check(machine(), rect);
315         m_coll_bit2 |= collision_check(rect);
318316
319317         // check collision sprite - foreground
320318
r20931r20932
325323
326324         drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0);
327325
328         m_coll_bit1 |= collision_check(machine(), rect);
326         m_coll_bit1 |= collision_check(rect);
329327
330328         // check collision sprite - sprite
331329
r20931r20932
366364
367365         drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0);
368366
369         m_coll_bit0 |= collision_check(machine(), rect);
367         m_coll_bit0 |= collision_check(rect);
370368      }
371369
372370      // check for bit 3 (sprite-sprite)
r20931r20932
447445
448446         drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0);
449447
450         m_coll_bit3 |= collision_check(machine(), rect);
448         m_coll_bit3 |= collision_check(rect);
451449      }
452450
453451      // check for bit 6
r20931r20932
528526
529527         drawgfx_transpen(m_helper2, rect, machine().gfx[1], code, 0, flipx, flipy, sx, sy, 0);
530528
531         m_coll_bit6 |= collision_check(machine(), rect);
529         m_coll_bit6 |= collision_check(rect);
532530      }
533531   }
534532}
trunk/src/mame/video/mjkjidai.c
r20931r20932
8181
8282***************************************************************************/
8383
84static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
84void mjkjidai_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
8585{
86   mjkjidai_state *state = machine.driver_data<mjkjidai_state>();
87   UINT8 *spriteram = state->m_spriteram1;
88   UINT8 *spriteram_2 = state->m_spriteram2;
89   UINT8 *spriteram_3 = state->m_spriteram3;
86   UINT8 *spriteram = m_spriteram1;
87   UINT8 *spriteram_2 = m_spriteram2;
88   UINT8 *spriteram_3 = m_spriteram3;
9089   int offs;
9190
9291   for (offs = 0x20-2;offs >= 0;offs -= 2)
r20931r20932
102101
103102      sx += (spriteram_2[offs] & 0x20) >> 5;  // not sure about this
104103
105      if (state->flip_screen())
104      if (flip_screen())
106105      {
107106         sx = 496 - sx;
108107         sy = 240 - sy;
r20931r20932
113112      sx += 16;
114113      sy += 1;
115114
116      drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
115      drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
117116            code,
118117            color,
119118            flipx,flipy,
r20931r20932
130129   else
131130   {
132131      m_bg_tilemap->draw(bitmap, cliprect, 0,0);
133      draw_sprites(machine(), bitmap,cliprect);
132      draw_sprites(bitmap,cliprect);
134133   }
135134   return 0;
136135}
trunk/src/mame/video/mcatadv.c
r20931r20932
4646}
4747
4848
49static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
49void mcatadv_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
5050{
51   mcatadv_state *state = machine.driver_data<mcatadv_state>();
52   UINT16 *source = state->m_spriteram_old;
53   UINT16 *finish = source + (state->m_spriteram.bytes() / 2) /2;
54   int global_x = state->m_vidregs[0] - 0x184;
55   int global_y = state->m_vidregs[1] - 0x1f1;
51   UINT16 *source = m_spriteram_old;
52   UINT16 *finish = source + (m_spriteram.bytes() / 2) /2;
53   int global_x = m_vidregs[0] - 0x184;
54   int global_y = m_vidregs[1] - 0x1f1;
5655
5756   UINT16 *destline;
5857   UINT8 *priline;
59   UINT8 *sprdata = state->memregion("gfx1")->base();
60   int sprmask = state->memregion("gfx1")->bytes()-1;
58   UINT8 *sprdata = memregion("gfx1")->base();
59   int sprmask = memregion("gfx1")->bytes()-1;
6160
6261   int xstart, xend, xinc;
6362   int ystart, yend, yinc;
6463
65   if (state->m_vidregs_old[2] == 0x0001) /* Double Buffered */
64   if (m_vidregs_old[2] == 0x0001) /* Double Buffered */
6665   {
67      source += (state->m_spriteram.bytes() / 2) / 2;
68      finish += (state->m_spriteram.bytes() / 2) / 2;
66      source += (m_spriteram.bytes() / 2) / 2;
67      finish += (m_spriteram.bytes() / 2) / 2;
6968   }
70   else if (state->m_vidregs_old[2]) /* I suppose it's possible that there is 4 banks, haven't seen it used though */
69   else if (m_vidregs_old[2]) /* I suppose it's possible that there is 4 banks, haven't seen it used though */
7170   {
7271      logerror("Spritebank != 0/1\n");
7372   }
r20931r20932
9493      if (y & 0x200) y-=0x400;
9594
9695#if 0 // For Flipscreen/Cocktail
97      if(state->m_vidregs[0] & 0x8000)
96      if(m_vidregs[0] & 0x8000)
9897      {
9998         flipx = !flipx;
10099      }
101      if(state->m_vidregs[1] & 0x8000)
100      if(m_vidregs[1] & 0x8000)
102101      {
103102         flipy = !flipy;
104103      }
r20931r20932
118117            if ((drawypos >= cliprect.min_y) && (drawypos <= cliprect.max_y))
119118            {
120119               destline = &bitmap.pix16(drawypos);
121               priline = &machine.priority_bitmap.pix8(drawypos);
120               priline = &machine().priority_bitmap.pix8(drawypos);
122121
123122               for (xcnt = xstart; xcnt != xend; xcnt += xinc)
124123               {
r20931r20932
152151   }
153152}
154153
155static void mcatadv_draw_tilemap_part( UINT16* current_scroll, UINT16* current_videoram1, int i, tilemap_t* current_tilemap, bitmap_ind16 &bitmap, const rectangle &cliprect )
154void mcatadv_state::mcatadv_draw_tilemap_part( UINT16* current_scroll, UINT16* current_videoram1, int i, tilemap_t* current_tilemap, bitmap_ind16 &bitmap, const rectangle &cliprect )
156155{
157156   int flip;
158157   UINT32 drawline;
r20931r20932
240239#ifdef MAME_DEBUG
241240   if (!machine().input().code_pressed(KEYCODE_E))
242241#endif
243      draw_sprites (machine(), bitmap, cliprect);
242      draw_sprites (bitmap, cliprect);
244243   g_profiler.stop();
245244   return 0;
246245}
trunk/src/mame/video/ms32.c
r20931r20932
119119/********** PALETTE WRITES **********/
120120
121121
122static void update_color(running_machine &machine, int color)
122void ms32_state::update_color(int color)
123123{
124   ms32_state *state = machine.driver_data<ms32_state>();
125124   int r,g,b;
126125
127126   /* I'm not sure how the brightness should be applied, currently I'm only
r20931r20932
130129    */
131130   if (~color & 0x4000)
132131   {
133      r = ((state->m_palram_16[color*2] & 0xff00) >>8 ) * state->m_brt_r / 0x100;
134      g = ((state->m_palram_16[color*2] & 0x00ff) >>0 ) * state->m_brt_g / 0x100;
135      b = ((state->m_palram_16[color*2+1] & 0x00ff) >>0 ) * state->m_brt_b / 0x100;
132      r = ((m_palram_16[color*2] & 0xff00) >>8 ) * m_brt_r / 0x100;
133      g = ((m_palram_16[color*2] & 0x00ff) >>0 ) * m_brt_g / 0x100;
134      b = ((m_palram_16[color*2+1] & 0x00ff) >>0 ) * m_brt_b / 0x100;
136135   }
137136   else
138137   {
139      r = ((state->m_palram_16[color*2] & 0xff00) >>8 );
140      g = ((state->m_palram_16[color*2] & 0x00ff) >>0 );
141      b = ((state->m_palram_16[color*2+1] & 0x00ff) >>0 );
138      r = ((m_palram_16[color*2] & 0xff00) >>8 );
139      g = ((m_palram_16[color*2] & 0x00ff) >>0 );
140      b = ((m_palram_16[color*2+1] & 0x00ff) >>0 );
142141   }
143142
144   palette_set_color(machine,color,MAKE_RGB(r,g,b));
143   palette_set_color(machine(),color,MAKE_RGB(r,g,b));
145144}
146145
147146WRITE32_MEMBER(ms32_state::ms32_brightness_w)
r20931r20932
194193
195194
196195/* SPRITES based on tetrisp2 for now, readd priority bits later */
197static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_pri, const rectangle &cliprect, UINT16 *sprram_top, size_t sprram_size, int gfxnum, int reverseorder)
196void ms32_state::draw_sprites(bitmap_ind16 &bitmap, bitmap_ind8 &bitmap_pri, const rectangle &cliprect, UINT16 *sprram_top, size_t sprram_size, int gfxnum, int reverseorder)
198197{
199198   int tx, ty, sx, sy, flipx, flipy;
200199   int xsize, ysize;
201200   int code, attr, color, size;
202201   int pri;
203202   int xzoom, yzoom;
204   gfx_element *gfx = machine.gfx[gfxnum];
203   gfx_element *gfx = machine().gfx[gfxnum];
205204
206205   UINT16      *source =   sprram_top;
207206   UINT16  *finish =   sprram_top + (sprram_size - 0x10) / 2;
r20931r20932
264263}
265264
266265
267static void draw_roz(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,int priority)
266void ms32_state::draw_roz(bitmap_ind16 &bitmap, const rectangle &cliprect,int priority)
268267{
269   ms32_state *state = machine.driver_data<ms32_state>();
270268   /* TODO: registers 0x40/4 / 0x44/4 and 0x50/4 / 0x54/4 are used, meaning unknown */
271269
272   if (state->m_roz_ctrl[0x5c/4] & 1)  /* "super" mode */
270   if (m_roz_ctrl[0x5c/4] & 1)  /* "super" mode */
273271   {
274272      rectangle my_clip;
275273      int y,maxy;
r20931r20932
282280
283281      while (y <= maxy)
284282      {
285         UINT16 *lineaddr = state->m_lineram_16 + 8 * (y & 0xff);
283         UINT16 *lineaddr = m_lineram_16 + 8 * (y & 0xff);
286284
287285         int start2x = (lineaddr[0x00/4] & 0xffff) | ((lineaddr[0x04/4] & 3) << 16);
288286         int start2y = (lineaddr[0x08/4] & 0xffff) | ((lineaddr[0x0c/4] & 3) << 16);
289287         int incxx  = (lineaddr[0x10/4] & 0xffff) | ((lineaddr[0x14/4] & 1) << 16);
290288         int incxy  = (lineaddr[0x18/4] & 0xffff) | ((lineaddr[0x1c/4] & 1) << 16);
291         int startx = (state->m_roz_ctrl[0x00/4] & 0xffff) | ((state->m_roz_ctrl[0x04/4] & 3) << 16);
292         int starty = (state->m_roz_ctrl[0x08/4] & 0xffff) | ((state->m_roz_ctrl[0x0c/4] & 3) << 16);
293         int offsx  = state->m_roz_ctrl[0x30/4];
294         int offsy  = state->m_roz_ctrl[0x34/4];
289         int startx = (m_roz_ctrl[0x00/4] & 0xffff) | ((m_roz_ctrl[0x04/4] & 3) << 16);
290         int starty = (m_roz_ctrl[0x08/4] & 0xffff) | ((m_roz_ctrl[0x0c/4] & 3) << 16);
291         int offsx  = m_roz_ctrl[0x30/4];
292         int offsy  = m_roz_ctrl[0x34/4];
295293
296294         my_clip.min_y = my_clip.max_y = y;
297295
298         offsx += (state->m_roz_ctrl[0x38/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
299         offsy += (state->m_roz_ctrl[0x3c/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
296         offsx += (m_roz_ctrl[0x38/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
297         offsy += (m_roz_ctrl[0x3c/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
300298
301299         /* extend sign */
302300         if (start2x & 0x20000) start2x |= ~0x3ffff;
r20931r20932
306304         if (incxx & 0x10000) incxx |= ~0x1ffff;
307305         if (incxy & 0x10000) incxy |= ~0x1ffff;
308306
309         state->m_roz_tilemap->draw_roz(bitmap, my_clip,
307         m_roz_tilemap->draw_roz(bitmap, my_clip,
310308               (start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16,
311309               incxx<<8, incxy<<8, 0, 0,
312310               1, // Wrap
r20931r20932
317315   }
318316   else    /* "simple" mode */
319317   {
320      int startx = (state->m_roz_ctrl[0x00/4] & 0xffff) | ((state->m_roz_ctrl[0x04/4] & 3) << 16);
321      int starty = (state->m_roz_ctrl[0x08/4] & 0xffff) | ((state->m_roz_ctrl[0x0c/4] & 3) << 16);
322      int incxx  = (state->m_roz_ctrl[0x10/4] & 0xffff) | ((state->m_roz_ctrl[0x14/4] & 1) << 16);
323      int incxy  = (state->m_roz_ctrl[0x18/4] & 0xffff) | ((state->m_roz_ctrl[0x1c/4] & 1) << 16);
324      int incyy  = (state->m_roz_ctrl[0x20/4] & 0xffff) | ((state->m_roz_ctrl[0x24/4] & 1) << 16);
325      int incyx  = (state->m_roz_ctrl[0x28/4] & 0xffff) | ((state->m_roz_ctrl[0x2c/4] & 1) << 16);
326      int offsx  = state->m_roz_ctrl[0x30/4];
327      int offsy  = state->m_roz_ctrl[0x34/4];
318      int startx = (m_roz_ctrl[0x00/4] & 0xffff) | ((m_roz_ctrl[0x04/4] & 3) << 16);
319      int starty = (m_roz_ctrl[0x08/4] & 0xffff) | ((m_roz_ctrl[0x0c/4] & 3) << 16);
320      int incxx  = (m_roz_ctrl[0x10/4] & 0xffff) | ((m_roz_ctrl[0x14/4] & 1) << 16);
321      int incxy  = (m_roz_ctrl[0x18/4] & 0xffff) | ((m_roz_ctrl[0x1c/4] & 1) << 16);
322      int incyy  = (m_roz_ctrl[0x20/4] & 0xffff) | ((m_roz_ctrl[0x24/4] & 1) << 16);
323      int incyx  = (m_roz_ctrl[0x28/4] & 0xffff) | ((m_roz_ctrl[0x2c/4] & 1) << 16);
324      int offsx  = m_roz_ctrl[0x30/4];
325      int offsy  = m_roz_ctrl[0x34/4];
328326
329      offsx += (state->m_roz_ctrl[0x38/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
330      offsy += (state->m_roz_ctrl[0x3c/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
327      offsx += (m_roz_ctrl[0x38/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
328      offsy += (m_roz_ctrl[0x3c/4] & 1) * 0x400;   // ??? gratia, hayaosi1...
331329
332330      /* extend sign */
333331      if (startx & 0x20000) startx |= ~0x3ffff;
r20931r20932
337335      if (incyy & 0x10000) incyy |= ~0x1ffff;
338336      if (incyx & 0x10000) incyx |= ~0x1ffff;
339337
340      state->m_roz_tilemap->draw_roz(bitmap, cliprect,
338      m_roz_tilemap->draw_roz(bitmap, cliprect,
341339            (startx+offsx)<<16, (starty+offsy)<<16,
342340            incxx<<8, incxy<<8, incyx<<8, incyy<<8,
343341            1, // Wrap
r20931r20932
365363   int i;
366364
367365   for (i = 0;i < 0x10000;i++) // colors 0x3000-0x3fff are not used
368      update_color(machine(), i);
366      update_color(i);
369367
370368   scrollx = m_tx_scroll[0x00/4] + m_tx_scroll[0x08/4] + 0x18;
371369   scrolly = m_tx_scroll[0x0c/4] + m_tx_scroll[0x14/4];
r20931r20932
392390   m_temp_bitmap_sprites.fill(0, cliprect);
393391   m_temp_bitmap_sprites_pri.fill(0, cliprect);
394392
395   draw_sprites(machine(), m_temp_bitmap_sprites, m_temp_bitmap_sprites_pri, cliprect, m_sprram_16, 0x20000, 0, m_reverse_sprite_order);
393   draw_sprites(m_temp_bitmap_sprites, m_temp_bitmap_sprites_pri, cliprect, m_sprram_16, 0x20000, 0, m_reverse_sprite_order);
396394
397395
398396
r20931r20932
415413      rot_pri++;
416414
417415   if (rot_pri == 0)
418      draw_roz(machine(), m_temp_bitmap_tilemaps, cliprect, 1 << 1);
416      draw_roz(m_temp_bitmap_tilemaps, cliprect, 1 << 1);
419417   else if (scr_pri == 0)
420418      if (m_tilemaplayoutcontrol&1)
421419      {
r20931r20932
429427      m_tx_tilemap->draw(m_temp_bitmap_tilemaps, cliprect, 0, 1 << 2);
430428
431429   if (rot_pri == 1)
432      draw_roz(machine(), m_temp_bitmap_tilemaps, cliprect, 1 << 1);
430      draw_roz(m_temp_bitmap_tilemaps, cliprect, 1 << 1);
433431   else if (scr_pri == 1)
434432      if (m_tilemaplayoutcontrol&1)
435433      {
r20931r20932
443441      m_tx_tilemap->draw(m_temp_bitmap_tilemaps, cliprect, 0, 1 << 2);
444442
445443   if (rot_pri == 2)
446      draw_roz(machine(), m_temp_bitmap_tilemaps, cliprect, 1 << 1);
444      draw_roz(m_temp_bitmap_tilemaps, cliprect, 1 << 1);
447445   else if (scr_pri == 2)
448446      if (m_tilemaplayoutcontrol&1)
449447      {
trunk/src/mame/video/mcr3.c
r20931r20932
194194 *
195195 *************************************/
196196
197static void mcr3_update_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int code_xor, int dx, int dy)
197void mcr3_state::mcr3_update_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int code_xor, int dx, int dy)
198198{
199   mcr3_state *state = machine.driver_data<mcr3_state>();
200   UINT8 *spriteram = state->m_spriteram;
199   UINT8 *spriteram = m_spriteram;
201200   int offs;
202201
203   machine.priority_bitmap.fill(1, cliprect);
202   machine().priority_bitmap.fill(1, cliprect);
204203
205204   /* loop over sprite RAM */
206   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
205   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
207206   {
208207      int code, color, flipx, flipy, sx, sy, flags;
209208
r20931r20932
241240      if (!mcr_cocktail_flip)
242241      {
243242         /* first draw the sprite, visible */
244         pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, sx, sy,
245               machine.priority_bitmap, 0x00, 0x0101);
243         pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, sx, sy,
244               machine().priority_bitmap, 0x00, 0x0101);
246245
247246         /* then draw the mask, behind the background but obscuring following sprites */
248         pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, flipx, flipy, sx, sy,
249               machine.priority_bitmap, 0x02, 0xfeff);
247         pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, flipx, flipy, sx, sy,
248               machine().priority_bitmap, 0x02, 0xfeff);
250249      }
251250      else
252251      {
253252         /* first draw the sprite, visible */
254         pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy,
255               machine.priority_bitmap, 0x00, 0x0101);
253         pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy,
254               machine().priority_bitmap, 0x00, 0x0101);
256255
257256         /* then draw the mask, behind the background but obscuring following sprites */
258         pdrawgfx_transmask(bitmap, cliprect, machine.gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy,
259               machine.priority_bitmap, 0x02, 0xfeff);
257         pdrawgfx_transmask(bitmap, cliprect, machine().gfx[1], code, color, !flipx, !flipy, 480 - sx, 452 - sy,
258               machine().priority_bitmap, 0x02, 0xfeff);
260259      }
261260   }
262261}
r20931r20932
278277   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
279278
280279   /* draw the sprites */
281   mcr3_update_sprites(machine(), bitmap, cliprect, 0x03, 0, 0, 0);
280   mcr3_update_sprites(bitmap, cliprect, 0x03, 0, 0, 0);
282281   return 0;
283282}
284283
r20931r20932
292291   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
293292
294293   /* draw the sprites */
295   mcr3_update_sprites(machine(), bitmap, cliprect, m_spyhunt_sprite_color_mask, 0, -12, 0);
294   mcr3_update_sprites(bitmap, cliprect, m_spyhunt_sprite_color_mask, 0, -12, 0);
296295
297296   /* render any characters on top */
298297   m_alpha_tilemap->draw(bitmap, cliprect, 0, 0);
trunk/src/mame/video/munchmo.c
r20931r20932
4646   m_tmpbitmap = auto_bitmap_ind16_alloc(machine(), 512, 512);
4747}
4848
49static void draw_status( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
49void munchmo_state::draw_status( bitmap_ind16 &bitmap, const rectangle &cliprect )
5050{
51   munchmo_state *state = machine.driver_data<munchmo_state>();
52   gfx_element *gfx = machine.gfx[0];
51   gfx_element *gfx = machine().gfx[0];
5352   int row;
5453
5554   for (row = 0; row < 4; row++)
5655   {
5756      int sy, sx = (row & 1) * 8;
58      const UINT8 *source = state->m_status_vram + (~row & 1) * 32;
57      const UINT8 *source = m_status_vram + (~row & 1) * 32;
5958      if (row <= 1)
6059      {
6160         source += 2 * 32;
r20931r20932
7473   }
7574}
7675
77static void draw_background( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
76void munchmo_state::draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect )
7877{
7978/*
8079    ROM B1.2C contains 256 tilemaps defining 4x4 configurations of
8180    the tiles in ROM B2.2B
8281*/
83   munchmo_state *state = machine.driver_data<munchmo_state>();
84   UINT8 *rom = state->memregion("gfx2")->base();
85   gfx_element *gfx = machine.gfx[1];
82   UINT8 *rom = memregion("gfx2")->base();
83   gfx_element *gfx = machine().gfx[1];
8684   int offs;
8785
8886   for (offs = 0; offs < 0x100; offs++)
8987   {
9088      int sy = (offs % 16) * 32;
9189      int sx = (offs / 16) * 32;
92      int tile_number = state->m_videoram[offs];
90      int tile_number = m_videoram[offs];
9391      int row, col;
9492
9593      for (row = 0; row < 4; row++)
9694      {
9795         for (col = 0; col < 4; col++)
9896         {
99            drawgfx_opaque(*state->m_tmpbitmap, state->m_tmpbitmap->cliprect(), gfx,
97            drawgfx_opaque(*m_tmpbitmap, m_tmpbitmap->cliprect(), gfx,
10098               rom[col + tile_number * 4 + row * 0x400],
101               state->m_palette_bank,
99               m_palette_bank,
102100               0,0, /* flip */
103101               sx + col * 8, sy + row * 8 );
104102         }
r20931r20932
106104   }
107105
108106   {
109      int scrollx = -(state->m_vreg[6] *2 + (state->m_vreg[7] >> 7)) - 64 - 128 - 16;
107      int scrollx = -(m_vreg[6] *2 + (m_vreg[7] >> 7)) - 64 - 128 - 16;
110108      int scrolly = 0;
111109
112      copyscrollbitmap(bitmap, *state->m_tmpbitmap, 1, &scrollx, 1, &scrolly, cliprect);
110      copyscrollbitmap(bitmap, *m_tmpbitmap, 1, &scrollx, 1, &scrolly, cliprect);
113111   }
114112}
115113
116static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
114void munchmo_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
117115{
118   munchmo_state *state = machine.driver_data<munchmo_state>();
119   int scroll = state->m_vreg[6];
120   int flags = state->m_vreg[7];                           /*   XB?????? */
116   int scroll = m_vreg[6];
117   int flags = m_vreg[7];                           /*   XB?????? */
121118   int xadjust = - 128 - 16 - ((flags & 0x80) ? 1 : 0);
122119   int bank = (flags & 0x40) ? 1 : 0;
123   gfx_element *gfx = machine.gfx[2 + bank];
124   int color_base = state->m_palette_bank * 4 + 3;
120   gfx_element *gfx = machine().gfx[2 + bank];
121   int color_base = m_palette_bank * 4 + 3;
125122   int i, j;
126   int firstsprite = state->m_vreg[4] & 0x3f;
123   int firstsprite = m_vreg[4] & 0x3f;
127124   for (i = firstsprite; i < firstsprite + 0x40; i++)
128125   {
129126      for (j = 0; j < 8; j++)
130127      {
131128         int offs = (j << 6) | (i & 0x3f);
132         int tile_number = state->m_sprite_tile[offs];       /*   ETTTTTTT */
133         int attributes = state->m_sprite_attr[offs];        /*   XYYYYYCC */
134         int sx = state->m_sprite_xpos[offs];                /*   XXXXXXX? */
129         int tile_number = m_sprite_tile[offs];       /*   ETTTTTTT */
130         int attributes = m_sprite_attr[offs];        /*   XYYYYYCC */
131         int sx = m_sprite_xpos[offs];                /*   XXXXXXX? */
135132         int sy = (offs >> 6) << 5;                  /* Y YY------ */
136133         sy += (attributes >> 2) & 0x1f;
137134         if( attributes & 0x80 )
r20931r20932
150147
151148UINT32 munchmo_state::screen_update_mnchmobl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
152149{
153   draw_background(machine(), bitmap, cliprect);
154   draw_sprites(machine(), bitmap, cliprect);
155   draw_status(machine(), bitmap, cliprect);
150   draw_background(bitmap, cliprect);
151   draw_sprites(bitmap, cliprect);
152   draw_status(bitmap, cliprect);
156153   return 0;
157154}
trunk/src/mame/video/mrflea.c
r20931r20932
3939   m_spriteram[offset] = data;
4040}
4141
42static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
42void mrflea_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
4343{
44   mrflea_state *state = machine.driver_data<mrflea_state>();
45   gfx_element *gfx = machine.gfx[0];
46   const UINT8 *source = state->m_spriteram;
44   gfx_element *gfx = machine().gfx[0];
45   const UINT8 *source = m_spriteram;
4746   const UINT8 *finish = source + 0x100;
48   rectangle clip = machine.primary_screen->visible_area();
47   rectangle clip = machine().primary_screen->visible_area();
4948
5049   clip.max_x -= 24;
5150   clip.min_x += 16;
r20931r20932
7069   }
7170}
7271
73static void draw_background( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
72void mrflea_state::draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect )
7473{
75   mrflea_state *state = machine.driver_data<mrflea_state>();
76   const UINT8 *source = state->m_videoram;
77   gfx_element *gfx = machine.gfx[1];
74   const UINT8 *source = m_videoram;
75   gfx_element *gfx = machine().gfx[1];
7876   int sx, sy;
7977   int base = 0;
8078
81   if (BIT(state->m_gfx_bank, 2))
79   if (BIT(m_gfx_bank, 2))
8280      base |= 0x400;
8381
84   if (BIT(state->m_gfx_bank, 4))
82   if (BIT(m_gfx_bank, 4))
8583      base |= 0x200;
8684
8785   for (sy = 0; sy < 256; sy += 8)
r20931r20932
102100
103101UINT32 mrflea_state::screen_update_mrflea(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
104102{
105   draw_background(machine(), bitmap, cliprect);
106   draw_sprites(machine(), bitmap, cliprect);
103   draw_background(bitmap, cliprect);
104   draw_sprites(bitmap, cliprect);
107105   return 0;
108106}
trunk/src/mame/video/metro.c
r20931r20932
139139/* This looks up a single pixel in a tile, given the tile code.
140140   The Metro hardware has an indirection table, which is used here.
141141   Returns if to draw the pixel or not, pixel colour is placed in pix */
142INLINE UINT8 get_tile_pix( running_machine &machine, UINT16 code, UINT8 x, UINT8 y, int big, UINT16 *pix )
142inline UINT8 metro_state::get_tile_pix( UINT16 code, UINT8 x, UINT8 y, int big, UINT16 *pix )
143143{
144   metro_state *state = machine.driver_data<metro_state>();
145144   int table_index;
146145   UINT32 tile;
147146
148147   // Use code as an index into the tiles set table
149148   table_index = ((code & 0x1ff0) >> 4) * 2;
150   tile = (state->m_tiletable[table_index + 0] << 16) + state->m_tiletable[table_index + 1];
149   tile = (m_tiletable[table_index + 0] << 16) + m_tiletable[table_index + 1];
151150
152151   if (code & 0x8000) // Special: draw a tile of a single color (i.e. not from the gfx ROMs)
153152   {
r20931r20932
158157      else
159158         return 0;
160159   }
161   else if (((tile & 0x00f00000) == 0x00f00000)    && (state->m_support_8bpp)) /* draw tile as 8bpp (e.g. balcube bg) */
160   else if (((tile & 0x00f00000) == 0x00f00000)    && (m_support_8bpp)) /* draw tile as 8bpp (e.g. balcube bg) */
162161   {
163      gfx_element *gfx1 = machine.gfx[big?3:1];
162      gfx_element *gfx1 = machine().gfx[big?3:1];
164163      UINT32 tile2 = big ? ((tile & 0xfffff) + 8*(code & 0xf)) :
165164                        ((tile & 0xfffff) + 2*(code & 0xf));
166165      const UINT8* data;
r20931r20932
192191   }
193192   else
194193   {
195      gfx_element *gfx1 = machine.gfx[big?2:0];
194      gfx_element *gfx1 = machine().gfx[big?2:0];
196195      UINT32 tile2 = big ? ((tile & 0xfffff) + 4*(code & 0xf)) :
197196                        ((tile & 0xfffff) +   (code & 0xf));
198197      const UINT8* data;
r20931r20932
228227}
229228
230229
231INLINE void metro_vram_w( running_machine &machine, offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram )
230inline void metro_state::metro_vram_w( offs_t offset, UINT16 data, UINT16 mem_mask, int layer, UINT16 *vram )
232231{
233232   COMBINE_DATA(&vram[offset]);
234233}
235234
236WRITE16_MEMBER(metro_state::metro_vram_0_w){ metro_vram_w(machine(), offset, data, mem_mask, 0, m_vram_0); }
237WRITE16_MEMBER(metro_state::metro_vram_1_w){ metro_vram_w(machine(), offset, data, mem_mask, 1, m_vram_1); }
238WRITE16_MEMBER(metro_state::metro_vram_2_w){ metro_vram_w(machine(), offset, data, mem_mask, 2, m_vram_2); }
235WRITE16_MEMBER(metro_state::metro_vram_0_w){ metro_vram_w(offset, data, mem_mask, 0, m_vram_0); }
236WRITE16_MEMBER(metro_state::metro_vram_1_w){ metro_vram_w(offset, data, mem_mask, 1, m_vram_1); }
237WRITE16_MEMBER(metro_state::metro_vram_2_w){ metro_vram_w(offset, data, mem_mask, 2, m_vram_2); }
239238
240239
241240
r20931r20932
408407
409408***************************************************************************/
410409
411void metro_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
410void metro_state::metro_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
412411{
413   metro_state *state = machine.driver_data<metro_state>();
414   UINT8 *base_gfx4 = state->m_expanded_gfx1;
415   UINT8 *base_gfx8 = state->memregion("gfx1")->base();
416   UINT32 gfx_size = state->memregion("gfx1")->bytes();
412   UINT8 *base_gfx4 = m_expanded_gfx1;
413   UINT8 *base_gfx8 = memregion("gfx1")->base();
414   UINT32 gfx_size = memregion("gfx1")->bytes();
417415
418   int max_x = machine.primary_screen->width();
419   int max_y = machine.primary_screen->height();
416   int max_x = machine().primary_screen->width();
417   int max_y = machine().primary_screen->height();
420418
421   int max_sprites = state->m_spriteram.bytes() / 8;
422   int sprites     = state->m_videoregs[0x00/2] % max_sprites;
419   int max_sprites = m_spriteram.bytes() / 8;
420   int sprites     = m_videoregs[0x00/2] % max_sprites;
423421
424   int color_start = (state->m_videoregs[0x08/2] & 0x0f) << 4;
422   int color_start = (m_videoregs[0x08/2] & 0x0f) << 4;
425423
426424   int i, j, pri;
427425   static const int primask[4] = { 0x0000, 0xff00, 0xff00 | 0xf0f0, 0xff00 | 0xf0f0 | 0xcccc };
r20931r20932
434432
435433   for (i = 0; i < 0x20; i++)
436434   {
437      if (!(state->m_videoregs[0x02/2] & 0x8000))
435      if (!(m_videoregs[0x02/2] & 0x8000))
438436      {
439         src = state->m_spriteram + (sprites - 1) * (8 / 2);
437         src = m_spriteram + (sprites - 1) * (8 / 2);
440438         inc = -(8 / 2);
441439      } else {
442         src = state->m_spriteram;
440         src = m_spriteram;
443441         inc = (8 / 2);
444442      }
445443
r20931r20932
467465            continue;
468466         }
469467
470         pri = (state->m_videoregs[0x02/2] & 0x0300) >> 8;
468         pri = (m_videoregs[0x02/2] & 0x0300) >> 8;
471469
472         if (!(state->m_videoregs[0x02/2] & 0x8000))
470         if (!(m_videoregs[0x02/2] & 0x8000))
473471         {
474            if (curr_pri > (state->m_videoregs[0x02/2] & 0x1f))
475               pri = (state->m_videoregs[0x02/2] & 0x0c00) >> 10;
472            if (curr_pri > (m_videoregs[0x02/2] & 0x1f))
473               pri = (m_videoregs[0x02/2] & 0x0c00) >> 10;
476474         }
477475
478476         y     = src[1];
r20931r20932
485483
486484         zoom = zoomtable[(y & 0xfc00) >> 10] << (16 - 8);
487485
488         x = (x & 0x07ff) - state->m_sprite_xoffs;
489         y = (y & 0x03ff) - state->m_sprite_yoffs;
486         x = (x & 0x07ff) - m_sprite_xoffs;
487         y = (y & 0x03ff) - m_sprite_yoffs;
490488
491489         width  = (((attr >> 11) & 0x7) + 1) * 8;
492490         height = (((attr >>  8) & 0x7) + 1) * 8;
493491
494492         UINT32 gfxstart = (8 * 8 * 4 / 8) * (((attr & 0x000f) << 16) + code);
495493
496         if (state->m_flip_screen)
494         if (m_flip_screen)
497495         {
498496            flipx = !flipx;     x = max_x - x - width;
499497            flipy = !flipy;     y = max_y - y - height;
500498         }
501499
502         if (state->m_support_8bpp && color == 0xf)  /* 8bpp */
500         if (m_support_8bpp && color == 0xf)  /* 8bpp */
503501         {
504502            /* Bounds checking */
505503            if ((gfxstart + width * height - 1) >= gfx_size)
506504               continue;
507505
508            gfx_element gfx(machine, base_gfx8 + gfxstart, width, height, width, 0, 256);
506            gfx_element gfx(machine(), base_gfx8 + gfxstart, width, height, width, 0, 256);
509507
510508            pdrawgfxzoom_transpen(  bitmap,cliprect, &gfx,
511509                        0,
r20931r20932
513511                        flipx, flipy,
514512                        x, y,
515513                        zoom, zoom,
516                        machine.priority_bitmap,primask[pri], 255);
514                        machine().priority_bitmap,primask[pri], 255);
517515         }
518516         else
519517         {
r20931r20932
521519            if ((gfxstart + width / 2 * height - 1) >= gfx_size)
522520               continue;
523521
524            gfx_element gfx(machine, base_gfx4 + 2 * gfxstart, width, height, width, 0, 16);
522            gfx_element gfx(machine(), base_gfx4 + 2 * gfxstart, width, height, width, 0, 16);
525523
526524            pdrawgfxzoom_transpen(  bitmap,cliprect, &gfx,
527525                        0,
r20931r20932
529527                        flipx, flipy,
530528                        x, y,
531529                        zoom, zoom,
532                        machine.priority_bitmap,primask[pri], 15);
530                        machine().priority_bitmap,primask[pri], 15);
533531         }
534532#if 0
535533{   /* Display priority + zoom on each sprite */
r20931r20932
555553
556554// Copy a 'window' from the large 2048x2048 (or 4096x4096 for 16x16 tiles) tilemap
557555
558static void draw_tilemap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 flags, UINT32 pcode,
556void metro_state::draw_tilemap( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 flags, UINT32 pcode,
559557                     int sx, int sy, int wx, int wy, int big, UINT16 *tilemapram, int layer )
560558{
561   metro_state *state = machine.driver_data<metro_state>();
562559   int y;
563560
564   bitmap_ind8 &priority_bitmap = machine.priority_bitmap;
561   bitmap_ind8 &priority_bitmap = machine().priority_bitmap;
565562
566563   int width  = big ? 4096 : 2048;
567564   int height = big ? 4096 : 2048;
r20931r20932
572569   int windowwidth  = width >> 2;
573570   int windowheight = height >> 3;
574571
575   sx += state->m_tilemap_scrolldx[layer] * (state->m_flip_screen ? 1 : -1);
572   sx += m_tilemap_scrolldx[layer] * (m_flip_screen ? 1 : -1);
576573
577574   for (y = 0; y < scrheight; y++)
578575   {
r20931r20932
583580      int srcline = (wy+scrolly)&(height-1);
584581      int srctilerow = srcline >> (big ? 4 : 3);
585582
586      if (!state->m_flip_screen)
583      if (!m_flip_screen)
587584      {
588585         dst = &bitmap.pix16(y);
589586         priority_baseaddr = &priority_bitmap.pix8(y);
r20931r20932
598595            UINT16 dat = 0;
599596
600597            UINT16 tile = tilemapram[tileoffs];
601            UINT8 draw = get_tile_pix(machine, tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat);
598            UINT8 draw = get_tile_pix(tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat);
602599
603600            if (draw)
604601            {
r20931r20932
622619            UINT16 dat = 0;
623620
624621            UINT16 tile = tilemapram[tileoffs];
625            UINT8 draw = get_tile_pix(machine, tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat);
622            UINT8 draw = get_tile_pix(tile, big ? (srccol&0xf) : (srccol&0x7), big ? (srcline&0xf) : (srcline&0x7), big, &dat);
626623
627624            if (draw)
628625            {
r20931r20932
636633
637634// Draw all the layers that match the given priority
638635
639static void draw_layers( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int layers_ctrl )
636void metro_state::draw_layers( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int layers_ctrl )
640637{
641   metro_state *state = machine.driver_data<metro_state>();
642   UINT16 layers_pri = state->m_videoregs[0x10 / 2];
638   UINT16 layers_pri = m_videoregs[0x10 / 2];
643639   int layer;
644640
645641   // Draw all the layers with priority == pri
r20931r20932
648644      if (pri == ((layers_pri >> (layer * 2)) & 3))
649645      {
650646         // Scroll and Window values
651         UINT16 sy = state->m_scroll[layer * 2 + 0]; UINT16 sx = state->m_scroll[layer * 2 + 1];
652         UINT16 wy = state->m_window[layer * 2 + 0]; UINT16 wx = state->m_window[layer * 2 + 1];
647         UINT16 sy = m_scroll[layer * 2 + 0]; UINT16 sx = m_scroll[layer * 2 + 1];
648         UINT16 wy = m_window[layer * 2 + 0]; UINT16 wx = m_window[layer * 2 + 1];
653649
654650         if (BIT(layers_ctrl, layer))    // for debug
655651         {
r20931r20932
657653
658654            switch (layer)
659655            {
660               case 0: tilemapram = state->m_vram_0;   break;
661               case 1: tilemapram = state->m_vram_1;   break;
662               case 2: tilemapram = state->m_vram_2;   break;
656               case 0: tilemapram = m_vram_0;   break;
657               case 1: tilemapram = m_vram_1;   break;
658               case 2: tilemapram = m_vram_2;   break;
663659            }
664660
665            int big = state->m_support_16x16 && (*state->m_screenctrl & (0x0020 << layer));
661            int big = m_support_16x16 && (*m_screenctrl & (0x0020 << layer));
666662
667            draw_tilemap(machine, bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, big, tilemapram, layer);
663            draw_tilemap(bitmap, cliprect, 0, 1 << (3 - pri), sx, sy, wx, wy, big, tilemapram, layer);
668664         }
669665      }
670666   }
r20931r20932
723719      k053936_zoom_draw(m_k053936, bitmap, cliprect, m_k053936_tilemap, 0, 0, 1);
724720
725721   for (pri = 3; pri >= 0; pri--)
726      draw_layers(machine(), bitmap, cliprect, pri, layers_ctrl);
722      draw_layers(bitmap, cliprect, pri, layers_ctrl);
727723
728724   if (layers_ctrl & 0x08)
729      metro_draw_sprites(machine(), bitmap, cliprect);
725      metro_draw_sprites(bitmap, cliprect);
730726
731727   return 0;
732728}
trunk/src/mame/video/mikie.c
r20931r20932
138138   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(mikie_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
139139}
140140
141static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
141void mikie_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
142142{
143   mikie_state *state = machine.driver_data<mikie_state>();
144   UINT8 *spriteram = state->m_spriteram;
143   UINT8 *spriteram = m_spriteram;
145144   int offs;
146145
147   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
146   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
148147   {
149148      int gfxbank = (spriteram[offs + 2] & 0x40) ? 2 : 1;
150149      int code = (spriteram[offs + 2] & 0x3f) + ((spriteram[offs + 2] & 0x80) >> 1) + ((spriteram[offs] & 0x40) << 1);
151      int color = (spriteram[offs] & 0x0f) + 16 * state->m_palettebank;
150      int color = (spriteram[offs] & 0x0f) + 16 * m_palettebank;
152151      int sx = spriteram[offs + 3];
153152      int sy = 244 - spriteram[offs + 1];
154153      int flipx = ~spriteram[offs] & 0x10;
155154      int flipy = spriteram[offs] & 0x20;
156155
157      if (state->flip_screen())
156      if (flip_screen())
158157      {
159158         sy = 242 - sy;
160159         flipy = !flipy;
161160      }
162161
163162      drawgfx_transpen(bitmap, cliprect,
164         machine.gfx[gfxbank],
163         machine().gfx[gfxbank],
165164         code, color,
166165         flipx,flipy,
167166         sx,sy, 0);
r20931r20932
171170UINT32 mikie_state::screen_update_mikie(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
172171{
173172   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_CATEGORY(0), 0);
174   draw_sprites(machine(), bitmap, cliprect);
173   draw_sprites(bitmap, cliprect);
175174   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_CATEGORY(1), 0);
176175   return 0;
177176}
trunk/src/mame/video/madalien.c
r20931r20932
6565}
6666
6767
68INLINE int scan_helper(int col, int row, int section)
68inline int madalien_state::scan_helper(int col, int row, int section)
6969{
7070   return (section << 8) | ((~col & 0x0f) << 3) | row;
7171}
r20931r20932
159159}
160160
161161
162static void draw_edges(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip, int scroll_mode)
162void madalien_state::draw_edges(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip, int scroll_mode)
163163{
164   madalien_state *state = machine.driver_data<madalien_state>();
165164   rectangle clip_edge1;
166165   rectangle clip_edge2;
167166
r20931r20932
170169
171170   if (flip)
172171   {
173      clip_edge1.min_y = *state->m_edge1_pos | 0x80;
174      clip_edge2.max_y = (*state->m_edge2_pos & 0x7f) ^ 0x7f;
172      clip_edge1.min_y = *m_edge1_pos | 0x80;
173      clip_edge2.max_y = (*m_edge2_pos & 0x7f) ^ 0x7f;
175174   }
176175   else
177176   {
178      clip_edge1.max_y = (*state->m_edge1_pos & 0x7f) ^ 0x7f;
179      clip_edge2.min_y = *state->m_edge2_pos | 0x80;
177      clip_edge1.max_y = (*m_edge1_pos & 0x7f) ^ 0x7f;
178      clip_edge2.min_y = *m_edge2_pos | 0x80;
180179   }
181180
182181   clip_edge1 &= cliprect;
183182   clip_edge2 &= cliprect;
184183
185   state->m_tilemap_edge1[scroll_mode]->mark_all_dirty();
186   state->m_tilemap_edge2[scroll_mode]->mark_all_dirty();
184   m_tilemap_edge1[scroll_mode]->mark_all_dirty();
185   m_tilemap_edge2[scroll_mode]->mark_all_dirty();
187186
188   state->m_tilemap_edge1[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
189   state->m_tilemap_edge1[scroll_mode]->set_scrollx(0, -(*state->m_scroll & 0xfc));
190   state->m_tilemap_edge1[scroll_mode]->set_scrolly(0, *state->m_edge1_pos & 0x7f);
187   m_tilemap_edge1[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
188   m_tilemap_edge1[scroll_mode]->set_scrollx(0, -(*m_scroll & 0xfc));
189   m_tilemap_edge1[scroll_mode]->set_scrolly(0, *m_edge1_pos & 0x7f);
191190
192   state->m_tilemap_edge2[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX : TILEMAP_FLIPY);
193   state->m_tilemap_edge2[scroll_mode]->set_scrollx(0, -(*state->m_scroll & 0xfc));
194   state->m_tilemap_edge2[scroll_mode]->set_scrolly(0, *state->m_edge2_pos & 0x7f);
191   m_tilemap_edge2[scroll_mode]->set_flip(flip ? TILEMAP_FLIPX : TILEMAP_FLIPY);
192   m_tilemap_edge2[scroll_mode]->set_scrollx(0, -(*m_scroll & 0xfc));
193   m_tilemap_edge2[scroll_mode]->set_scrolly(0, *m_edge2_pos & 0x7f);
195194
196   state->m_tilemap_edge1[scroll_mode]->draw(bitmap, clip_edge1, 0, 0);
197   state->m_tilemap_edge2[scroll_mode]->draw(bitmap, clip_edge2, 0, 0);
195   m_tilemap_edge1[scroll_mode]->draw(bitmap, clip_edge1, 0, 0);
196   m_tilemap_edge2[scroll_mode]->draw(bitmap, clip_edge2, 0, 0);
198197}
199198
200199
201static void draw_headlight(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip)
200void madalien_state::draw_headlight(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip)
202201{
203   madalien_state *state = machine.driver_data<madalien_state>();
204   if (BIT(*state->m_video_flags, 0))
202   if (BIT(*m_video_flags, 0))
205203   {
206204      UINT8 y;
207205
208206      for (y = 0; y < 0x80; y++)
209207      {
210208         UINT8 x;
211         UINT8 hy = y - *state->m_headlight_pos;
209         UINT8 hy = y - *m_headlight_pos;
212210
213211         if (flip)
214212            hy = ~hy;
r20931r20932
226224            if ((hx < cliprect.min_x) || (hx > cliprect.max_x))
227225               continue;
228226
229            if (state->m_headlight_bitmap->pix16(y, x) != 0)
227            if (m_headlight_bitmap->pix16(y, x) != 0)
230228               bitmap.pix16(hy, hx) |= 8;
231229         }
232230      }
r20931r20932
234232}
235233
236234
237static void draw_foreground(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip)
235void madalien_state::draw_foreground(bitmap_ind16 &bitmap, const rectangle &cliprect, int flip)
238236{
239   madalien_state *state = machine.driver_data<madalien_state>();
240   state->m_tilemap_fg->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
241   state->m_tilemap_fg->draw(bitmap, cliprect, 0, 0);
237   m_tilemap_fg->set_flip(flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
238   m_tilemap_fg->draw(bitmap, cliprect, 0, 0);
242239}
243240
244241
r20931r20932
263260   int scroll_mode = *m_scroll & 3;
264261
265262   bitmap.fill(0, cliprect);
266   draw_edges(machine(), bitmap, cliprect, flip, scroll_mode);
267   draw_foreground(machine(), bitmap, cliprect, flip);
263   draw_edges(bitmap, cliprect, flip, scroll_mode);
264   draw_foreground(bitmap, cliprect, flip);
268265
269266   /* highlight section A (outside of tunnels).
270267    * also, bit 1 of the video_flags register (6A) is
r20931r20932
298295               bitmap.pix16(y, x) |= 8;
299296   }
300297
301   draw_headlight(machine(), bitmap, cliprect, flip);
298   draw_headlight(bitmap, cliprect, flip);
302299
303300   return 0;
304301}
trunk/src/mame/video/mrjong.c
r20931r20932
107107/*
108108Note: First 0x40 entries in the videoram are actually spriteram
109109*/
110static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
110void mrjong_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
111111{
112   mrjong_state *state = machine.driver_data<mrjong_state>();
113112   int offs;
114113
115114   for (offs = (0x40 - 4); offs >= 0; offs -= 4)
r20931r20932
119118      int sx, sy;
120119      int flipx, flipy;
121120
122      sprt = (((state->m_videoram[offs + 1] >> 2) & 0x3f) | ((state->m_videoram[offs + 3] & 0x20) << 1));
123      flipx = (state->m_videoram[offs + 1] & 0x01) >> 0;
124      flipy = (state->m_videoram[offs + 1] & 0x02) >> 1;
125      color = (state->m_videoram[offs + 3] & 0x1f);
121      sprt = (((m_videoram[offs + 1] >> 2) & 0x3f) | ((m_videoram[offs + 3] & 0x20) << 1));
122      flipx = (m_videoram[offs + 1] & 0x01) >> 0;
123      flipy = (m_videoram[offs + 1] & 0x02) >> 1;
124      color = (m_videoram[offs + 3] & 0x1f);
126125
127      sx = 224 - state->m_videoram[offs + 2];
128      sy = state->m_videoram[offs + 0];
129      if (state->flip_screen())
126      sx = 224 - m_videoram[offs + 2];
127      sy = m_videoram[offs + 0];
128      if (flip_screen())
130129      {
131130         sx = 208 - sx;
132131         sy = 240 - sy;
r20931r20932
134133         flipy = !flipy;
135134      }
136135
137      drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
136      drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
138137            sprt,
139138            color,
140139            flipx, flipy,
r20931r20932
145144UINT32 mrjong_state::screen_update_mrjong(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
146145{
147146   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
148   draw_sprites(machine(), bitmap, cliprect);
147   draw_sprites(bitmap, cliprect);
149148   return 0;
150149}
trunk/src/mame/video/meadows.c
r20931r20932
7474 *
7575 *************************************/
7676
77static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &clip)
77void meadows_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &clip)
7878{
79   meadows_state *state = machine.driver_data<meadows_state>();
80   UINT8 *spriteram = state->m_spriteram;
79   UINT8 *spriteram = m_spriteram;
8180   int i;
8281
8382   for (i = 0; i < 4; i++)
r20931r20932
8988      int bank = i;                           /* that fixes it for now :-/ */
9089      int flip = spriteram[i+8] >> 5;         /* bit #5 flip vertical flag */
9190
92      drawgfx_transpen(bitmap, clip, machine.gfx[bank + 1], code, 0, flip, 0, x, y, 0);
91      drawgfx_transpen(bitmap, clip, machine().gfx[bank + 1], code, 0, flip, 0, x, y, 0);
9392   }
9493}
9594
r20931r20932
108107
109108   /* draw the sprites */
110109   if (machine().gfx[1])
111      draw_sprites(machine(), bitmap, cliprect);
110      draw_sprites(bitmap, cliprect);
112111   return 0;
113112}
trunk/src/mame/video/m52.c
r20931r20932
290290 *
291291 *************************************/
292292
293void draw_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int xpos, int ypos, int image)
293void m52_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect, int xpos, int ypos, int image)
294294{
295295   rectangle rect;
296   const rectangle &visarea = machine.primary_screen->visible_area();
296   const rectangle &visarea = machine().primary_screen->visible_area();
297297
298   m52_state *state = machine.driver_data<m52_state>();
299298
300   if (state->flip_screen())
299   if (flip_screen())
301300   {
302301      xpos = 127 - xpos;
303302      ypos = 255 - ypos - BGHEIGHT;
r20931r20932
309308   ypos = ypos + (22 - 8);
310309
311310   drawgfx_transpen(bitmap, cliprect,
312      machine.gfx[image],
311      machine().gfx[image],
313312      0, 0,
314      state->flip_screen(),
315      state->flip_screen(),
313      flip_screen(),
314      flip_screen(),
316315      xpos,
317316      ypos, 0);
318317
319318   drawgfx_transpen(bitmap, cliprect,
320      machine.gfx[image],
319      machine().gfx[image],
321320      0, 0,
322      state->flip_screen(),
323      state->flip_screen(),
321      flip_screen(),
322      flip_screen(),
324323      xpos - 256,
325324      ypos, 0);
326325
327326   rect.min_x = visarea.min_x;
328327   rect.max_x = visarea.max_x;
329328
330   if (state->flip_screen())
329   if (flip_screen())
331330   {
332331      rect.min_y = ypos - BGHEIGHT;
333332      rect.max_y = ypos - 1;
r20931r20932
338337      rect.max_y = ypos + 2 * BGHEIGHT - 1;
339338   }
340339
341   bitmap.fill(machine.gfx[image]->colorbase() + 3, rect);
340   bitmap.fill(machine().gfx[image]->colorbase() + 3, rect);
342341}
343342
344343
r20931r20932
358357   if (!(m_bgcontrol & 0x20))
359358   {
360359      if (!(m_bgcontrol & 0x10))
361         draw_background(machine(), bitmap, cliprect, m_bg2xpos, m_bg2ypos, 2); /* distant mountains */
360         draw_background(bitmap, cliprect, m_bg2xpos, m_bg2ypos, 2); /* distant mountains */
362361
363362      if (!(m_bgcontrol & 0x02))
364         draw_background(machine(), bitmap, cliprect, m_bg1xpos, m_bg1ypos, 3); /* hills */
363         draw_background(bitmap, cliprect, m_bg1xpos, m_bg1ypos, 3); /* hills */
365364
366365      if (!(m_bgcontrol & 0x04))
367         draw_background(machine(), bitmap, cliprect, m_bg1xpos, m_bg1ypos, 4); /* cityscape */
366         draw_background(bitmap, cliprect, m_bg1xpos, m_bg1ypos, 4); /* cityscape */
368367   }
369368
370369   m_bg_tilemap->set_flip(flip_screen() ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
trunk/src/mame/video/mustache.c
r20931r20932
9696   m_bg_tilemap->set_scroll_rows(4);
9797}
9898
99static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
99void mustache_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
100100{
101   mustache_state *state = machine.driver_data<mustache_state>();
102101   rectangle clip = cliprect;
103   gfx_element *gfx = machine.gfx[1];
104   const rectangle &visarea = machine.primary_screen->visible_area();
105   UINT8 *spriteram = state->m_spriteram;
102   gfx_element *gfx = machine().gfx[1];
103   const rectangle &visarea = machine().primary_screen->visible_area();
104   UINT8 *spriteram = m_spriteram;
106105   int offs;
107106
108   for (offs = 0;offs < state->m_spriteram.bytes();offs += 4)
107   for (offs = 0;offs < m_spriteram.bytes();offs += 4)
109108   {
110109      int sy = 240-spriteram[offs];
111110      int sx = 240-spriteram[offs+3];
r20931r20932
117116
118117      code+=(attr&0x0c)<<6;
119118
120      if ((state->m_control_byte & 0xa))
119      if ((m_control_byte & 0xa))
121120         clip.max_y = visarea.max_y;
122121      else
123         if (state->flip_screen())
122         if (flip_screen())
124123            clip.min_y = visarea.min_y + 56;
125124         else
126125            clip.max_y = visarea.max_y - 56;
127126
128      if (state->flip_screen())
127      if (flip_screen())
129128      {
130129         sx = 240 - sx;
131130         sy = 240 - sy;
r20931r20932
134133      drawgfx_transpen(bitmap,clip,gfx,
135134            code,
136135            color,
137            state->flip_screen(),state->flip_screen(),
136            flip_screen(),flip_screen(),
138137            sx,sy,0);
139138   }
140139}
r20931r20932
142141UINT32 mustache_state::screen_update_mustache(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
143142{
144143   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
145   draw_sprites(machine(), bitmap, cliprect);
144   draw_sprites(bitmap, cliprect);
146145   return 0;
147146}
trunk/src/mame/video/msisaac.c
r20931r20932
147147  Display refresh
148148
149149***************************************************************************/
150static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
150void msisaac_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
151151{
152   msisaac_state *state = machine.driver_data<msisaac_state>();
153   const UINT8 *source = state->m_spriteram + 32 * 4 - 4;
154   const UINT8 *finish = state->m_spriteram; /* ? */
152   const UINT8 *source = m_spriteram + 32 * 4 - 4;
153   const UINT8 *finish = m_spriteram; /* ? */
155154
156155   while (source >= finish)
157156   {
r20931r20932
164163      int flipx = (attributes & 0x1);
165164      int flipy = (attributes & 0x2);
166165
167      gfx_element *gfx = machine.gfx[2];
166      gfx_element *gfx = machine().gfx[2];
168167
169168      if (attributes & 4)
170169      {
171170         //color = rand() & 15;
172         gfx = machine.gfx[3];
171         gfx = machine().gfx[3];
173172      }
174173
175174      if (attributes & 8) /* double size sprite */
r20931r20932
234233{
235234   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
236235   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
237   draw_sprites(machine(), bitmap, cliprect);
236   draw_sprites(bitmap, cliprect);
238237   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
239238   return 0;
240239}
trunk/src/mame/video/markham.c
r20931r20932
7171   m_bg_tilemap->set_scroll_rows(32);
7272}
7373
74static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
74void markham_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
7575{
76   markham_state *state = machine.driver_data<markham_state>();
77   UINT8 *spriteram = state->m_spriteram;
76   UINT8 *spriteram = m_spriteram;
7877   int offs;
7978
8079   for (offs = 0x60; offs < 0x100; offs += 4)
r20931r20932
8281      int chr = spriteram[offs + 1];
8382      int col = spriteram[offs + 2];
8483
85      int fx = state->flip_screen();
86      int fy = state->flip_screen();
84      int fx = flip_screen();
85      int fy = flip_screen();
8786
8887      int x = spriteram[offs + 3];
8988      int y = spriteram[offs + 0];
9089      int px, py;
9190      col &= 0x3f ;
9291
93      if (state->flip_screen() == 0)
92      if (flip_screen() == 0)
9493      {
9594         px = x - 2;
9695         py = 240 - y;
r20931r20932
106105      if (px > 248)
107106         px = px - 256;
108107
109      drawgfx_transmask(bitmap,cliprect,machine.gfx[1],
108      drawgfx_transmask(bitmap,cliprect,machine().gfx[1],
110109         chr,
111110         col,
112111         fx,fy,
113112         px,py,
114         colortable_get_transpen_mask(machine.colortable, machine.gfx[1], col, 0));
113         colortable_get_transpen_mask(machine().colortable, machine().gfx[1], col, 0));
115114   }
116115}
117116
r20931r20932
128127   }
129128
130129   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
131   draw_sprites(machine(), bitmap, cliprect);
130   draw_sprites(bitmap, cliprect);
132131   return 0;
133132}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team