Previous 199869 Revisions Next

r20974 Tuesday 12th February, 2013 at 10:01:14 UTC by Miodrag Milanović
Modernization of drivers part 15 (no whatsnew)
[src/mame/drivers]pacman.c parodius.c pirates.c playmark.c plygonet.c powerbal.c psikyo.c psikyo4.c
[src/mame/includes]pacland.h pacman.h pandoras.h paradise.h pastelg.h pbaction.h pcktgal.h pingpong.h pirates.h pitnrun.h playch10.h playmark.h plygonet.h pokechmp.h polepos.h policetr.h pooyan.h popeye.h popper.h portrait.h powerins.h prehisle.h psikyo.h psikyo4.h psikyosh.h psychic5.h punchout.h pushman.h
[src/mame/machine]playch10.c
[src/mame/video]pacland.c pacman.c pandoras.c paradise.c pastelg.c pbaction.c pcktgal.c pingpong.c pirates.c pitnrun.c playmark.c pokechmp.c polepos.c policetr.c pooyan.c popeye.c popper.c portrait.c powerins.c prehisle.c psikyo.c psikyo4.c psikyosh.c psychic5.c punchout.c pushman.c

trunk/src/mame/drivers/plygonet.c
r20973r20974
542542
543543/**********************************************************************************/
544544
545static void reset_sound_region(running_machine &machine)
545void polygonet_state::reset_sound_region()
546546{
547   polygonet_state *state = machine.driver_data<polygonet_state>();
548   state->membank("bank2")->set_base(state->memregion("soundcpu")->base() + 0x10000 + state->m_cur_sound_region*0x4000);
547   membank("bank2")->set_base(memregion("soundcpu")->base() + 0x10000 + m_cur_sound_region*0x4000);
549548}
550549
551550WRITE8_MEMBER(polygonet_state::sound_bankswitch_w)
552551{
553552   m_cur_sound_region = (data & 0x1f);
554   reset_sound_region(machine());
553   reset_sound_region();
555554}
556555
557556INTERRUPT_GEN_MEMBER(polygonet_state::audio_interrupt)
r20973r20974
726725{
727726   /* Set default bankswitch */
728727   m_cur_sound_region = 2;
729   reset_sound_region(machine());
728   reset_sound_region();
730729
731730   /* Allocate space for the dsp56k banking */
732731   memset(m_dsp56k_bank00_ram, 0, sizeof(m_dsp56k_bank00_ram));
trunk/src/mame/drivers/powerbal.c
r20973r20974
387387   SET_TILE_INFO_MEMBER(1, code, colr >> 12, 0);
388388}
389389
390static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
390void playmark_state::draw_sprites_powerbal(bitmap_ind16 &bitmap, const rectangle &cliprect )
391391{
392   playmark_state *state = machine.driver_data<playmark_state>();
393   UINT16 *spriteram = state->m_spriteram;
392   UINT16 *spriteram = m_spriteram;
394393   int offs;
395   int height = machine.gfx[0]->height();
394   int height = machine().gfx[0]->height();
396395
397   for (offs = 4; offs < state->m_spriteram.bytes() / 2; offs += 4)
396   for (offs = 4; offs < m_spriteram.bytes() / 2; offs += 4)
398397   {
399398      int sx, sy, code, color, flipx;
400399
r20973r20974
408407      code = spriteram[offs + 2];
409408      color = (spriteram[offs + 1] & 0xf000) >> 12;
410409
411      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
410      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
412411            code,
413412            color,
414413            flipx,0,
415            sx + state->m_xoffset,sy + state->m_yoffset,0);
414            sx + m_xoffset,sy + m_yoffset,0);
416415   }
417416}
418417
r20973r20974
428427UINT32 playmark_state::screen_update_powerbal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
429428{
430429   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
431   draw_sprites(machine(), bitmap, cliprect);
430   draw_sprites_powerbal(bitmap, cliprect);
432431   return 0;
433432}
434433
trunk/src/mame/drivers/pacman.c
r20973r20974
57685768 *
57695769 *************************************/
57705770
5771static void maketrax_rom_decode(running_machine &machine)
5771void pacman_state::maketrax_rom_decode()
57725772{
5773   pacman_state *state = machine.driver_data<pacman_state>();
5774   address_space &space = state->m_maincpu->space(AS_PROGRAM);
5775   UINT8 *decrypted = auto_alloc_array(machine, UINT8, 0x4000);
5776   UINT8 *rom = machine.root_device().memregion("maincpu")->base();
5773   address_space &space = m_maincpu->space(AS_PROGRAM);
5774   UINT8 *decrypted = auto_alloc_array(machine(), UINT8, 0x4000);
5775   UINT8 *rom = machine().root_device().memregion("maincpu")->base();
57775776
57785777   /* patch protection using a copy of the opcodes so ROM checksum */
57795778   /* tests will not fail */
r20973r20974
57985797   m_maincpu->space(AS_PROGRAM).install_read_handler(0x5080, 0x50bf, read8_delegate(FUNC(pacman_state::maketrax_special_port2_r),this));
57995798   m_maincpu->space(AS_PROGRAM).install_read_handler(0x50c0, 0x50ff, read8_delegate(FUNC(pacman_state::maketrax_special_port3_r),this));
58005799
5801   maketrax_rom_decode(machine());
5800   maketrax_rom_decode();
58025801}
58035802
5804static void korosuke_rom_decode(running_machine &machine)
5803void pacman_state::korosuke_rom_decode()
58055804{
5806   pacman_state *state = machine.driver_data<pacman_state>();
5807   address_space &space = state->m_maincpu->space(AS_PROGRAM);
5808   UINT8 *decrypted = auto_alloc_array(machine, UINT8, 0x4000);
5809   UINT8 *rom = machine.root_device().memregion("maincpu")->base();
5805   address_space &space = m_maincpu->space(AS_PROGRAM);
5806   UINT8 *decrypted = auto_alloc_array(machine(), UINT8, 0x4000);
5807   UINT8 *rom = machine().root_device().memregion("maincpu")->base();
58105808
58115809   /* patch protection using a copy of the opcodes so ROM checksum */
58125810   /* tests will not fail */
r20973r20974
58315829   m_maincpu->space(AS_PROGRAM).install_read_handler(0x5080, 0x5080, read8_delegate(FUNC(pacman_state::korosuke_special_port2_r),this));
58325830   m_maincpu->space(AS_PROGRAM).install_read_handler(0x50c0, 0x50ff, read8_delegate(FUNC(pacman_state::korosuke_special_port3_r),this));
58335831
5834   korosuke_rom_decode(machine());
5832   korosuke_rom_decode();
58355833}
58365834
58375835DRIVER_INIT_MEMBER(pacman_state,ponpoko)
r20973r20974
58705868   }
58715869}
58725870
5873static void eyes_decode(UINT8 *data)
5871void pacman_state::eyes_decode(UINT8 *data)
58745872{
58755873   int j;
58765874   UINT8 swapbuffer[8];
r20973r20974
59175915#define BITSWAP11(val,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \
59185916   BITSWAP16(val,15,14,13,12,11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0)
59195917
5920static void mspacman_install_patches(UINT8 *ROM)
5918void pacman_state::mspacman_install_patches(UINT8 *ROM)
59215919{
59225920   int i;
59235921
trunk/src/mame/drivers/parodius.c
r20973r20974
106106
107107#if 0
108108
109static void sound_nmi_callback( running_machine &machine, int param )
109void parodius_state::sound_nmi_callback( int param )
110110{
111   parodius_state *state = machine.driver_data<parodius_state>();
112   state->m_audiocpu->set_input_line(INPUT_LINE_NMI, ( state->m_nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
111   m_audiocpu->set_input_line(INPUT_LINE_NMI, ( m_nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
113112
114113   nmi_enabled = 0;
115114}
trunk/src/mame/drivers/playmark.c
r20973r20974
16931693ROM_END
16941694
16951695
1696static UINT8 playmark_asciitohex(UINT8 data)
1696UINT8 playmark_state::playmark_asciitohex(UINT8 data)
16971697{
16981698   /* Convert ASCII data to HEX */
16991699
trunk/src/mame/drivers/psikyo4.c
r20973r20974
322322   }
323323}
324324
325#define PCM_BANK_NO_LEGACY(n)   ((state->m_io_select[0] >> (n * 4 + 24)) & 0x07)
325#define PCM_BANK_NO_LEGACY(n)   ((m_io_select[0] >> (n * 4 + 24)) & 0x07)
326326
327static void set_hotgmck_pcm_bank( running_machine &machine, int n )
327void psikyo4_state::set_hotgmck_pcm_bank( int n )
328328{
329   psikyo4_state *state = machine.driver_data<psikyo4_state>();
330   UINT8 *ymf_pcmbank = state->memregion("ymf")->base() + 0x200000;
331   UINT8 *pcm_rom = state->memregion("ymfsource")->base();
329   UINT8 *ymf_pcmbank = memregion("ymf")->base() + 0x200000;
330   UINT8 *pcm_rom = memregion("ymfsource")->base();
332331
333332   memcpy(ymf_pcmbank + n * 0x100000, pcm_rom + PCM_BANK_NO_LEGACY(n) * 0x100000, 0x100000);
334333}
r20973r20974
345344   new_bank1 = PCM_BANK_NO(1);
346345
347346   if (old_bank0 != new_bank0)
348      set_hotgmck_pcm_bank(machine(), 0);
347      set_hotgmck_pcm_bank(0);
349348
350349   if (old_bank1 != new_bank1)
351      set_hotgmck_pcm_bank(machine(), 1);
350      set_hotgmck_pcm_bank(1);
352351}
353352
354353static ADDRESS_MAP_START( ps4_map, AS_PROGRAM, 32, psikyo4_state )
r20973r20974
940939
941940void psikyo4_state::hotgmck_pcm_bank_postload()
942941{
943   set_hotgmck_pcm_bank(machine(), 0);
944   set_hotgmck_pcm_bank(machine(), 1);
942   set_hotgmck_pcm_bank(0);
943   set_hotgmck_pcm_bank(1);
945944}
946945
947static void install_hotgmck_pcm_bank(running_machine &machine)
946void psikyo4_state::install_hotgmck_pcm_bank()
948947{
949   psikyo4_state *state = machine.driver_data<psikyo4_state>();
950   UINT8 *ymf_pcm = state->memregion("ymf")->base();
951   UINT8 *pcm_rom = state->memregion("ymfsource")->base();
948   UINT8 *ymf_pcm = memregion("ymf")->base();
949   UINT8 *pcm_rom = memregion("ymfsource")->base();
952950
953951   memcpy(ymf_pcm, pcm_rom, 0x200000);
954952
955   state->m_io_select[0] = (state->m_io_select[0] & 0x00ffffff) | 0x32000000;
956   set_hotgmck_pcm_bank(machine, 0);
957   set_hotgmck_pcm_bank(machine, 1);
953   m_io_select[0] = (m_io_select[0] & 0x00ffffff) | 0x32000000;
954   set_hotgmck_pcm_bank(0);
955   set_hotgmck_pcm_bank(1);
958956
959   machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x5800008, 0x580000b, write32_delegate(FUNC(psikyo4_state::hotgmck_pcm_bank_w),state));
960   machine.save().register_postload(save_prepost_delegate(FUNC(psikyo4_state::hotgmck_pcm_bank_postload), state));
957   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x5800008, 0x580000b, write32_delegate(FUNC(psikyo4_state::hotgmck_pcm_bank_w),this));
958   machine().save().register_postload(save_prepost_delegate(FUNC(psikyo4_state::hotgmck_pcm_bank_postload), this));
961959}
962960
963961DRIVER_INIT_MEMBER(psikyo4_state,hotgmck)
964962{
965963   UINT8 *RAM = machine().root_device().memregion("maincpu")->base();
966964   machine().root_device().membank("bank1")->set_base(&RAM[0x100000]);
967   install_hotgmck_pcm_bank(machine());    // Banked PCM ROM
965   install_hotgmck_pcm_bank();    // Banked PCM ROM
968966}
969967
970968
trunk/src/mame/drivers/pirates.c
r20973r20974
335335
336336/* Init */
337337
338static void pirates_decrypt_68k(running_machine &machine)
338void pirates_state::pirates_decrypt_68k()
339339{
340340   int rom_size;
341341   UINT16 *buf, *rom;
342342   int i;
343343
344   rom_size = machine.root_device().memregion("maincpu")->bytes();
344   rom_size = machine().root_device().memregion("maincpu")->bytes();
345345
346   buf = auto_alloc_array(machine, UINT16, rom_size/2);
346   buf = auto_alloc_array(machine(), UINT16, rom_size/2);
347347
348   rom = (UINT16 *)machine.root_device().memregion("maincpu")->base();
348   rom = (UINT16 *)machine().root_device().memregion("maincpu")->base();
349349   memcpy (buf, rom, rom_size);
350350
351351   for (i=0; i<rom_size/2; i++)
r20973r20974
361361
362362      rom[i] = (vr<<8) | vl;
363363   }
364   auto_free (machine, buf);
364   auto_free (machine(), buf);
365365}
366366
367static void pirates_decrypt_p(running_machine &machine)
367void pirates_state::pirates_decrypt_p()
368368{
369369   int rom_size;
370370   UINT8 *buf, *rom;
371371   int i;
372372
373   rom_size = machine.root_device().memregion("gfx1")->bytes();
373   rom_size = machine().root_device().memregion("gfx1")->bytes();
374374
375   buf = auto_alloc_array(machine, UINT8, rom_size);
375   buf = auto_alloc_array(machine(), UINT8, rom_size);
376376
377   rom = machine.root_device().memregion("gfx1")->base();
377   rom = machine().root_device().memregion("gfx1")->base();
378378   memcpy (buf, rom, rom_size);
379379
380380   for (i=0; i<rom_size/4; i++)
r20973r20974
385385      rom[adr+2*(rom_size/4)] = BITSWAP8(buf[i+2*(rom_size/4)], 1,4,7,0,3,5,6,2);
386386      rom[adr+3*(rom_size/4)] = BITSWAP8(buf[i+3*(rom_size/4)], 2,3,4,0,7,5,1,6);
387387   }
388   auto_free (machine, buf);
388   auto_free (machine(), buf);
389389}
390390
391static void pirates_decrypt_s(running_machine &machine)
391void pirates_state::pirates_decrypt_s()
392392{
393393   int rom_size;
394394   UINT8 *buf, *rom;
395395   int i;
396396
397   rom_size = machine.root_device().memregion("gfx2")->bytes();
397   rom_size = machine().root_device().memregion("gfx2")->bytes();
398398
399   buf = auto_alloc_array(machine, UINT8, rom_size);
399   buf = auto_alloc_array(machine(), UINT8, rom_size);
400400
401   rom = machine.root_device().memregion("gfx2")->base();
401   rom = machine().root_device().memregion("gfx2")->base();
402402   memcpy (buf, rom, rom_size);
403403
404404   for (i=0; i<rom_size/4; i++)
r20973r20974
409409      rom[adr+2*(rom_size/4)] = BITSWAP8(buf[i+2*(rom_size/4)], 2,3,4,0,7,5,1,6);
410410      rom[adr+3*(rom_size/4)] = BITSWAP8(buf[i+3*(rom_size/4)], 4,2,7,1,6,5,0,3);
411411   }
412   auto_free (machine, buf);
412   auto_free (machine(), buf);
413413}
414414
415415
416static void pirates_decrypt_oki(running_machine &machine)
416void pirates_state::pirates_decrypt_oki()
417417{
418418   int rom_size;
419419   UINT8 *buf, *rom;
420420   int i;
421421
422   rom_size = machine.root_device().memregion("oki")->bytes();
422   rom_size = machine().root_device().memregion("oki")->bytes();
423423
424   buf = auto_alloc_array(machine, UINT8, rom_size);
424   buf = auto_alloc_array(machine(), UINT8, rom_size);
425425
426   rom = machine.root_device().memregion("oki")->base();
426   rom = machine().root_device().memregion("oki")->base();
427427   memcpy (buf, rom, rom_size);
428428
429429   for (i=0; i<rom_size; i++)
r20973r20974
431431      int adr = BITSWAP24(i,23,22,21,20,19,10,16,13,8,4,7,11,14,17,12,6,2,0,5,18,15,3,1,9);
432432      rom[adr] = BITSWAP8(buf[i], 2,3,4,0,7,5,1,6);
433433   }
434   auto_free (machine, buf);
434   auto_free (machine(), buf);
435435}
436436
437437
r20973r20974
439439{
440440   UINT16 *rom = (UINT16 *)machine().root_device().memregion("maincpu")->base();
441441
442   pirates_decrypt_68k(machine());
443   pirates_decrypt_p(machine());
444   pirates_decrypt_s(machine());
445   pirates_decrypt_oki(machine());
442   pirates_decrypt_68k();
443   pirates_decrypt_p();
444   pirates_decrypt_s();
445   pirates_decrypt_oki();
446446
447447   /* patch out protection check */
448448   rom[0x62c0/2] = 0x6006; // beq -> bra
r20973r20974
452452
453453DRIVER_INIT_MEMBER(pirates_state,genix)
454454{
455   pirates_decrypt_68k(machine());
456   pirates_decrypt_p(machine());
457   pirates_decrypt_s(machine());
458   pirates_decrypt_oki(machine());
455   pirates_decrypt_68k();
456   pirates_decrypt_p();
457   pirates_decrypt_s();
458   pirates_decrypt_oki();
459459
460460   /* If this value is increased then something has gone wrong and the protection failed */
461461   /* Write-protect it for now */
trunk/src/mame/drivers/psikyo.c
r20973r20974
208208      m_s1945_mcu_direction = data;
209209      break;
210210   case 0x07:
211      psikyo_switch_banks(machine(), 1, (data >> 6) & 3);
212      psikyo_switch_banks(machine(), 0, (data >> 4) & 3);
211      psikyo_switch_banks(1, (data >> 6) & 3);
212      psikyo_switch_banks(0, (data >> 4) & 3);
213213      m_s1945_mcu_bctrl = data;
214214      break;
215215   case 0x0b:
r20973r20974
18311831#endif
18321832}
18331833
1834static void s1945_mcu_init( running_machine &machine )
1834void psikyo_state::s1945_mcu_init(  )
18351835{
1836   psikyo_state *state = machine.driver_data<psikyo_state>();
1837   state->m_s1945_mcu_direction = 0x00;
1838   state->m_s1945_mcu_inlatch = 0xff;
1839   state->m_s1945_mcu_latch1 = 0xff;
1840   state->m_s1945_mcu_latch2 = 0xff;
1841   state->m_s1945_mcu_latching = 0x5;
1842   state->m_s1945_mcu_control = 0xff;
1843   state->m_s1945_mcu_index = 0;
1844   state->m_s1945_mcu_mode = 0;
1845   state->m_s1945_mcu_bctrl = 0x00;
1836   m_s1945_mcu_direction = 0x00;
1837   m_s1945_mcu_inlatch = 0xff;
1838   m_s1945_mcu_latch1 = 0xff;
1839   m_s1945_mcu_latch2 = 0xff;
1840   m_s1945_mcu_latching = 0x5;
1841   m_s1945_mcu_control = 0xff;
1842   m_s1945_mcu_index = 0;
1843   m_s1945_mcu_mode = 0;
1844   m_s1945_mcu_bctrl = 0x00;
18461845
1847   state->save_item(NAME(state->m_s1945_mcu_direction));
1848   state->save_item(NAME(state->m_s1945_mcu_inlatch));
1849   state->save_item(NAME(state->m_s1945_mcu_latch1));
1850   state->save_item(NAME(state->m_s1945_mcu_latch2));
1851   state->save_item(NAME(state->m_s1945_mcu_latching));
1852   state->save_item(NAME(state->m_s1945_mcu_control));
1853   state->save_item(NAME(state->m_s1945_mcu_index));
1854   state->save_item(NAME(state->m_s1945_mcu_mode));
1855   state->save_item(NAME(state->m_s1945_mcu_bctrl));
1846   save_item(NAME(m_s1945_mcu_direction));
1847   save_item(NAME(m_s1945_mcu_inlatch));
1848   save_item(NAME(m_s1945_mcu_latch1));
1849   save_item(NAME(m_s1945_mcu_latch2));
1850   save_item(NAME(m_s1945_mcu_latching));
1851   save_item(NAME(m_s1945_mcu_control));
1852   save_item(NAME(m_s1945_mcu_index));
1853   save_item(NAME(m_s1945_mcu_mode));
1854   save_item(NAME(m_s1945_mcu_bctrl));
18561855}
18571856
18581857DRIVER_INIT_MEMBER(psikyo_state,tengai)
r20973r20974
18661865   /* protection */
18671866   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xc00004, 0xc0000b, write32_delegate(FUNC(psikyo_state::s1945_mcu_w),this));
18681867
1869   s1945_mcu_init(machine());
1868   s1945_mcu_init();
18701869   m_s1945_mcu_table = 0;
18711870
18721871   m_ka302c_banking = 0; // Banking is controlled by mcu
r20973r20974
19031902   /* protection and tile bank switching */
19041903   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xc00004, 0xc0000b, write32_delegate(FUNC(psikyo_state::s1945_mcu_w),this));
19051904
1906   s1945_mcu_init(machine());
1905   s1945_mcu_init();
19071906   m_s1945_mcu_table = s1945_table;
19081907
19091908   m_ka302c_banking = 0; // Banking is controlled by mcu
r20973r20974
19241923   /* protection and tile bank switching */
19251924   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xc00004, 0xc0000b, write32_delegate(FUNC(psikyo_state::s1945_mcu_w),this));
19261925
1927   s1945_mcu_init(machine());
1926   s1945_mcu_init();
19281927   m_s1945_mcu_table = s1945a_table;
19291928
19301929   m_ka302c_banking = 0; // Banking is controlled by mcu
r20973r20974
19451944   /* protection and tile bank switching */
19461945   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xc00004, 0xc0000b, write32_delegate(FUNC(psikyo_state::s1945_mcu_w),this));
19471946
1948   s1945_mcu_init(machine());
1947   s1945_mcu_init();
19491948   m_s1945_mcu_table = s1945j_table;
19501949
19511950   m_ka302c_banking = 0; // Banking is controlled by mcu
trunk/src/mame/machine/playch10.c
r20973r20974
44#include "machine/nvram.h"
55#include "includes/playch10.h"
66
7/* prototypes */
8static void pc10_set_videorom_bank( running_machine &machine, int first, int count, int bank, int size );
9static void set_videoram_bank( running_machine &machine, int first, int count, int bank, int size );
10
11
127/*************************************
138 *
149 *  Init machine
r20973r20974
5550   machine().device("ppu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2000, 0x3eff, read8_delegate(FUNC(playch10_state::pc10_nt_r),this),write8_delegate(FUNC(playch10_state::pc10_nt_w),this));
5651
5752   if (NULL != m_vram)
58      set_videoram_bank(machine(), 0, 8, 0, 8);
59   else pc10_set_videorom_bank(machine(), 0, 8, 0, 8);
53      set_videoram_bank(0, 8, 0, 8);
54   else pc10_set_videorom_bank(0, 8, 0, 8);
6055
6156   nvram_device *nvram = machine().device<nvram_device>("nvram");
6257   if (nvram != NULL)
r20973r20974
355350 *  64         1 *
356351\*****************/
357352
358static void pc10_set_videorom_bank( running_machine &machine, int first, int count, int bank, int size )
353void playch10_state::pc10_set_videorom_bank( int first, int count, int bank, int size )
359354{
360   playch10_state *state = machine.driver_data<playch10_state>();
361355   int i, len;
362356   /* first = first bank to map */
363357   /* count = number of 1K banks to map */
r20973r20974
368362   /* yeah, this is probably a horrible assumption to make.*/
369363   /* but the driver is 100% consistant */
370364
371   len = state->memregion("gfx2")->bytes();
365   len = memregion("gfx2")->bytes();
372366   len /= 0x400;   // convert to KB
373367   len /= size;    // convert to bank resolution
374368   len--;          // convert to mask
r20973r20974
376370
377371   for (i = 0; i < count; i++)
378372   {
379      state->m_chr_page[i + first].writable = 0;
380      state->m_chr_page[i + first].chr=state->m_vrom + (i * 0x400) + (bank * size * 0x400);
373      m_chr_page[i + first].writable = 0;
374      m_chr_page[i + first].chr=m_vrom + (i * 0x400) + (bank * size * 0x400);
381375   }
382376}
383377
384static void set_videoram_bank( running_machine &machine, int first, int count, int bank, int size )
378void playch10_state::set_videoram_bank( int first, int count, int bank, int size )
385379{
386   playch10_state *state = machine.driver_data<playch10_state>();
387380   int i;
388381   /* first = first bank to map */
389382   /* count = number of 1K banks to map */
r20973r20974
397390
398391   for (i = 0; i < count; i++)
399392   {
400      state->m_chr_page[i + first].writable = 1;
401      state->m_chr_page[i + first].chr = state->m_vram + (((i * 0x400) + (bank * size * 0x400)) & 0x1fff);
393      m_chr_page[i + first].writable = 1;
394      m_chr_page[i + first].chr = m_vram + (((i * 0x400) + (bank * size * 0x400)) & 0x1fff);
402395   }
403396}
404397
r20973r20974
525518
526519         case 1: /* video rom banking - bank 0 - 4k or 8k */
527520            if (m_vram)
528               set_videoram_bank(machine(), 0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
521               set_videoram_bank(0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
529522            else
530               pc10_set_videorom_bank(machine(), 0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
523               pc10_set_videorom_bank(0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
531524         break;
532525
533526         case 2: /* video rom banking - bank 1 - 4k only */
534527            if (vrom4k)
535528            {
536529               if (m_vram)
537                  set_videoram_bank(machine(), 0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
530                  set_videoram_bank(0, (vrom4k) ? 4 : 8, (m_mmc1_shiftreg & 0x1f), 4);
538531               else
539                  pc10_set_videorom_bank(machine(), 4, 4, (m_mmc1_shiftreg & 0x1f), 4);
532                  pc10_set_videorom_bank(4, 4, (m_mmc1_shiftreg & 0x1f), 4);
540533            }
541534         break;
542535
r20973r20974
575568
576569WRITE8_MEMBER(playch10_state::aboard_vrom_switch_w)
577570{
578   pc10_set_videorom_bank(machine(), 0, 8, (data & 3), 8);
571   pc10_set_videorom_bank(0, 8, (data & 3), 8);
579572}
580573
581574DRIVER_INIT_MEMBER(playch10_state,pcaboard)
r20973r20974
624617   /* set the mirroring here */
625618   m_mirroring = PPU_MIRROR_VERT;
626619   /* special init */
627   set_videoram_bank(machine(), 0, 8, 0, 8);
620   set_videoram_bank(0, 8, 0, 8);
628621}
629622
630623/**********************************************************************************/
r20973r20974
632625
633626WRITE8_MEMBER(playch10_state::cboard_vrom_switch_w)
634627{
635   pc10_set_videorom_bank(machine(), 0, 8, ((data >> 1) & 1), 8);
628   pc10_set_videorom_bank(0, 8, ((data >> 1) & 1), 8);
636629}
637630
638631DRIVER_INIT_MEMBER(playch10_state,pccboard)
r20973r20974
669662   /* allocate vram */
670663   m_vram = auto_alloc_array(machine(), UINT8, 0x2000);
671664   /* special init */
672   set_videoram_bank(machine(), 0, 8, 0, 8);
665   set_videoram_bank(0, 8, 0, 8);
673666}
674667
675668/* D Board games with extra ram (Metroid) */
r20973r20974
685678   /* allocate vram */
686679   m_vram = auto_alloc_array(machine(), UINT8, 0x2000);
687680   /* special init */
688   set_videoram_bank(machine(), 0, 8, 0, 8);
681   set_videoram_bank(0, 8, 0, 8);
689682}
690683
691684/**********************************************************************************/
r20973r20974
699692   if((offset & 0x1ff0) == 0x0fd0 && state->m_MMC2_bank_latch[0] != 0xfd)
700693   {
701694      state->m_MMC2_bank_latch[0] = 0xfd;
702      pc10_set_videorom_bank(ppu->machine(), 0, 4, state->m_MMC2_bank[0], 4);
695      state->pc10_set_videorom_bank(0, 4, state->m_MMC2_bank[0], 4);
703696   }
704697   else if((offset & 0x1ff0) == 0x0fe0 && state->m_MMC2_bank_latch[0] != 0xfe)
705698   {
706699      state->m_MMC2_bank_latch[0] = 0xfe;
707      pc10_set_videorom_bank(ppu->machine(), 0, 4, state->m_MMC2_bank[1], 4);
700      state->pc10_set_videorom_bank(0, 4, state->m_MMC2_bank[1], 4);
708701   }
709702   else if((offset & 0x1ff0) == 0x1fd0 && state->m_MMC2_bank_latch[1] != 0xfd)
710703   {
711704      state->m_MMC2_bank_latch[1] = 0xfd;
712      pc10_set_videorom_bank(ppu->machine(), 4, 4, state->m_MMC2_bank[2], 4);
705      state->pc10_set_videorom_bank(4, 4, state->m_MMC2_bank[2], 4);
713706   }
714707   else if((offset & 0x1ff0) == 0x1fe0 && state->m_MMC2_bank_latch[1] != 0xfe)
715708   {
716709      state->m_MMC2_bank_latch[1] = 0xfe;
717      pc10_set_videorom_bank(ppu->machine(), 4, 4, state->m_MMC2_bank[3], 4);
710      state->pc10_set_videorom_bank(4, 4, state->m_MMC2_bank[3], 4);
718711   }
719712}
720713
r20973r20974
734727      case 0x3000: /* gfx bank 0 - 4k */
735728         m_MMC2_bank[0] = data;
736729         if (m_MMC2_bank_latch[0] == 0xfd)
737            pc10_set_videorom_bank(machine(), 0, 4, data, 4);
730            pc10_set_videorom_bank(0, 4, data, 4);
738731      break;
739732
740733      case 0x4000: /* gfx bank 0 - 4k */
741734         m_MMC2_bank[1] = data;
742735         if (m_MMC2_bank_latch[0] == 0xfe)
743            pc10_set_videorom_bank(machine(), 0, 4, data, 4);
736            pc10_set_videorom_bank(0, 4, data, 4);
744737      break;
745738
746739      case 0x5000: /* gfx bank 1 - 4k */
747740         m_MMC2_bank[2] = data;
748741         if (m_MMC2_bank_latch[1] == 0xfd)
749            pc10_set_videorom_bank(machine(), 4, 4, data, 4);
742            pc10_set_videorom_bank(4, 4, data, 4);
750743      break;
751744
752745      case 0x6000: /* gfx bank 1 - 4k */
753746         m_MMC2_bank[3] = data;
754747         if (m_MMC2_bank_latch[1] == 0xfe)
755            pc10_set_videorom_bank(machine(), 4, 4, data, 4);
748            pc10_set_videorom_bank(4, 4, data, 4);
756749      break;
757750
758751      case 0x7000: /* mirroring */
r20973r20974
898891               case 1: /* char banking */
899892                  data &= 0xfe;
900893                  page ^= (cmd << 1);
901                  pc10_set_videorom_bank(machine(), page, 2, data, 1);
894                  pc10_set_videorom_bank(page, 2, data, 1);
902895               break;
903896
904897               case 2: /* char banking */
r20973r20974
906899               case 4: /* char banking */
907900               case 5: /* char banking */
908901                  page ^= cmd + 2;
909                  pc10_set_videorom_bank(machine(), page, 1, data, 1);
902                  pc10_set_videorom_bank(page, 1, data, 1);
910903               break;
911904
912905               case 6: /* program banking */
r20973r20974
10531046   /* allocate vram */
10541047   m_vram = auto_alloc_array(machine(), UINT8, 0x2000);
10551048   /* special init */
1056   set_videoram_bank(machine(), 0, 8, 0, 8);
1049   set_videoram_bank(0, 8, 0, 8);
10571050}
10581051
10591052/**********************************************************************************/
r20973r20974
10761069                  page ^= (cmd << 1);
10771070                  if (data & 0x40)
10781071                  {
1079                     set_videoram_bank(machine(), page, 2, data, 1);
1072                     set_videoram_bank(page, 2, data, 1);
10801073                  }
10811074                  else
10821075                  {
1083                     pc10_set_videorom_bank(machine(), page, 2, data, 1);
1076                     pc10_set_videorom_bank(page, 2, data, 1);
10841077                  }
10851078               return;
10861079
r20973r20974
10911084                  page ^= cmd + 2;
10921085                  if (data & 0x40)
10931086                  {
1094                     set_videoram_bank(machine(), page, 1, data, 1);
1087                     set_videoram_bank(page, 1, data, 1);
10951088                  }
10961089                  else
10971090                  {
1098                     pc10_set_videorom_bank(machine(), page, 1, data, 1);
1091                     pc10_set_videorom_bank(page, 1, data, 1);
10991092                  }
11001093               return;
11011094            }
r20973r20974
11531146   /* allocate vram */
11541147   m_vram = auto_alloc_array(machine(), UINT8, 0x2000);
11551148   /* special init */
1156   set_videoram_bank(machine(), 0, 8, 0, 8);
1149   set_videoram_bank(0, 8, 0, 8);
11571150}
trunk/src/mame/includes/powerins.h
r20973r20974
3131   virtual void machine_reset();
3232   virtual void video_start();
3333   UINT32 screen_update_powerins(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
34   void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
3435};
trunk/src/mame/includes/paradise.h
r20973r20974
5555   UINT32 screen_update_torus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5656   UINT32 screen_update_madball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5757   INTERRUPT_GEN_MEMBER(paradise_irq);
58   void update_pix_palbank();
59   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5860};
trunk/src/mame/includes/punchout.h
r20973r20974
6868   UINT32 screen_update_armwrest_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6969   UINT32 screen_update_armwrest_bottom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7070   INTERRUPT_GEN_MEMBER(vblank_irq);
71   void draw_big_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int palette);
72   void armwrest_draw_big_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int palette);
73   void drawbs2(bitmap_ind16 &bitmap, const rectangle &cliprect);
74   void punchout_copy_top_palette(int bank);
75   void punchout_copy_bot_palette(int bank);
7176};
trunk/src/mame/includes/polepos.h
r20973r20974
8484   DECLARE_PALETTE_INIT(polepos);
8585   UINT32 screen_update_polepos(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8686   TIMER_DEVICE_CALLBACK_MEMBER(polepos_scanline);
87   void draw_road(bitmap_ind16 &bitmap);
88   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
89   void zoom_sprite(bitmap_ind16 &bitmap,int big,UINT32 code,UINT32 color,int flipx,int sx,int sy,int sizex,int sizey);
8790};
8891
8992
trunk/src/mame/includes/popeye.h
r20973r20974
4242   DECLARE_PALETTE_INIT(popeyebl);
4343   UINT32 screen_update_popeye(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444   INTERRUPT_GEN_MEMBER(popeye_interrupt);
45   void convert_color_prom(const UINT8 *color_prom);
46   void set_background_palette(int bank);
47   void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect);
48   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4549};
trunk/src/mame/includes/prehisle.h
r20973r20974
2828   TILE_GET_INFO_MEMBER(get_fg_tile_info);
2929   virtual void video_start();
3030   UINT32 screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
31   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int foreground );
3132};
trunk/src/mame/includes/psikyo.h
r20973r20974
9393   UINT32 screen_update_psikyo_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
9494   void screen_eof_psikyo(screen_device &screen, bool state);
9595   TIMER_CALLBACK_MEMBER(psikyo_soundlatch_callback);
96   void psikyo_switch_banks( int tmap, int bank );
97   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen );
98   void draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen );
99   int tilemap_width( int size );
100   void s1945_mcu_init(  );
96101};
97102
98103/*----------- defined in video/psikyo.c -----------*/
trunk/src/mame/includes/pushman.h
r20973r20974
4949   DECLARE_MACHINE_RESET(pushman);
5050   DECLARE_MACHINE_RESET(bballs);
5151   UINT32 screen_update_pushman(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
52   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5253};
trunk/src/mame/includes/pitnrun.h
r20973r20974
5757   TIMER_CALLBACK_MEMBER(pitnrun_mcu_real_data_w);
5858   TIMER_CALLBACK_MEMBER(pitnrun_mcu_data_real_r);
5959   TIMER_CALLBACK_MEMBER(pitnrun_mcu_status_real_w);
60   void pitnrun_spotlights();
61   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
6062};
trunk/src/mame/includes/pastelg.h
r20973r20974
3636   virtual void palette_init();
3737   UINT32 screen_update_pastelg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3838   TIMER_CALLBACK_MEMBER(blitter_timer_callback);
39   int pastelg_blitter_src_addr_r(address_space &space);
40   void pastelg_vramflip();
41   void pastelg_gfxdraw();
3942};
4043
4144/*----------- defined in video/pastelg.c -----------*/
trunk/src/mame/includes/playmark.h
r20973r20974
107107   UINT32 screen_update_excelsr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
108108   UINT32 screen_update_hrdtimes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
109109   UINT32 screen_update_powerbal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
110   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift );
111   void bigtwinb_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift );
112   void draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect );
113   UINT8 playmark_asciitohex(UINT8 data);
114   void draw_sprites_powerbal( bitmap_ind16 &bitmap, const rectangle &cliprect );
110115};
trunk/src/mame/includes/portrait.h
r20973r20974
2727   virtual void video_start();
2828   virtual void palette_init();
2929   UINT32 screen_update_portrait(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
30   inline void get_tile_info( tile_data &tileinfo, int tile_index, const UINT8 *source );
31   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3032};
trunk/src/mame/includes/popper.h
r20973r20974
5656   virtual void palette_init();
5757   UINT32 screen_update_popper(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5858   INTERRUPT_GEN_MEMBER(vblank_irq);
59   void draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect );
5960};
trunk/src/mame/includes/plygonet.h
r20973r20974
7575   UINT32 screen_update_polygonet(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7676   INTERRUPT_GEN_MEMBER(polygonet_interrupt);
7777   INTERRUPT_GEN_MEMBER(audio_interrupt);
78   void reset_sound_region();
7879};
trunk/src/mame/includes/pacland.h
r20973r20974
4040   UINT32 screen_update_pacland(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4141   INTERRUPT_GEN_MEMBER(main_vblank_irq);
4242   INTERRUPT_GEN_MEMBER(mcu_vblank_irq);
43   void switch_palette();
44   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int whichmask);
45   void draw_fg(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
4346};
trunk/src/mame/includes/psikyo4.h
r20973r20974
5454   UINT32 screen_update_psikyo4_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   INTERRUPT_GEN_MEMBER(psikyosh_interrupt);
5656   void hotgmck_pcm_bank_postload();
57   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 scr );
58   void set_hotgmck_pcm_bank( int n );
59   void install_hotgmck_pcm_bank();
5760};
trunk/src/mame/includes/psychic5.h
r20973r20974
4848   UINT32 screen_update_psychic5(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
4949   UINT32 screen_update_bombsa(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5050   TIMER_DEVICE_CALLBACK_MEMBER(psychic5_scanline);
51   void psychic5_change_palette(int color, int offset);
52   void psychic5_change_bg_palette(int color, int lo_offs, int hi_offs);
53   void set_background_palette_intensity();
54   void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect);
55   void draw_background(bitmap_rgb32 &bitmap, const rectangle &cliprect);
5156};
trunk/src/mame/includes/pingpong.h
r20973r20974
2929   UINT32 screen_update_pingpong(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3030   TIMER_DEVICE_CALLBACK_MEMBER(pingpong_interrupt);
3131   TIMER_DEVICE_CALLBACK_MEMBER(merlinmm_interrupt);
32   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
3233};
trunk/src/mame/includes/pokechmp.h
r20973r20974
1818   TILE_GET_INFO_MEMBER(get_bg_tile_info);
1919   virtual void video_start();
2020   UINT32 screen_update_pokechmp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
21   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
2122};
trunk/src/mame/includes/pbaction.h
r20973r20974
5454   UINT32 screen_update_pbaction(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5555   INTERRUPT_GEN_MEMBER(pbaction_interrupt);
5656   INTERRUPT_GEN_MEMBER(vblank_irq);
57   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5758};
trunk/src/mame/includes/playch10.h
r20973r20974
118118   UINT32 screen_update_playch10_bottom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
119119   UINT32 screen_update_playch10_single(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
120120   INTERRUPT_GEN_MEMBER(playch10_interrupt);
121   void pc10_set_videorom_bank( int first, int count, int bank, int size );
122   void set_videoram_bank( int first, int count, int bank, int size );
121123};
122124
123125/*----------- defined in video/playch10.c -----------*/
trunk/src/mame/includes/psikyosh.h
r20973r20974
33#define MASTER_CLOCK 57272700   // main oscillator frequency
44
55/* Psikyo PS6406B */
6#define FLIPSCREEN (((state->m_vidregs[3] & 0x0000c000) == 0x0000c000) ? 1:0)
7#define DISPLAY_DISABLE (((state->m_vidregs[2] & 0x0000000f) == 0x00000006) ? 1:0)
8#define BG_LARGE(n) (((state->m_vidregs[7] << (4*n)) & 0x00001000 ) ? 1:0)
9#define BG_DEPTH_8BPP(n) (((state->m_vidregs[7] << (4*n)) & 0x00004000 ) ? 1:0)
10#define BG_LAYER_ENABLE(n) (((state->m_vidregs[7] << (4*n)) & 0x00008000 ) ? 1:0)
6#define FLIPSCREEN (((m_vidregs[3] & 0x0000c000) == 0x0000c000) ? 1:0)
7#define DISPLAY_DISABLE (((m_vidregs[2] & 0x0000000f) == 0x00000006) ? 1:0)
8#define BG_LARGE(n) (((m_vidregs[7] << (4*n)) & 0x00001000 ) ? 1:0)
9#define BG_DEPTH_8BPP(n) (((m_vidregs[7] << (4*n)) & 0x00004000 ) ? 1:0)
10#define BG_LAYER_ENABLE(n) (((m_vidregs[7] << (4*n)) & 0x00008000 ) ? 1:0)
1111
12#define BG_TYPE(n) (((state->m_vidregs[6] << (8*n)) & 0x7f000000 ) >> 24)
13#define BG_LINE(n) (((state->m_vidregs[6] << (8*n)) & 0x80000000 ) ? 1:0)
12#define BG_TYPE(n) (((m_vidregs[6] << (8*n)) & 0x7f000000 ) >> 24)
13#define BG_LINE(n) (((m_vidregs[6] << (8*n)) & 0x80000000 ) ? 1:0)
1414
1515#define BG_TRANSPEN MAKE_ARGB(0x00,0xff,0x00,0xff) // used for representing transparency in temporary bitmaps
1616
17#define SPRITE_PRI(n) (((state->m_vidregs[2] << (4*n)) & 0xf0000000 ) >> 28)
17#define SPRITE_PRI(n) (((m_vidregs[2] << (4*n)) & 0xf0000000 ) >> 28)
1818
1919
2020class psikyosh_state : public driver_device
r20973r20974
6767   virtual void video_start();
6868   UINT32 screen_update_psikyosh(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
6969   INTERRUPT_GEN_MEMBER(psikyosh_interrupt);
70   void draw_scanline32_alpha(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, int alpha);
71   void draw_scanline32_argb(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr);
72   void draw_scanline32_transpen(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr);
73   void draw_bglayer( int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri );
74   void cache_bitmap(int scanline, gfx_element *gfx, int size, int tilebank, int alpha, int *last_bank);
75   void draw_bglayerscroll( int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri );
76   void draw_background( bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri );
77   void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri);
78   void psikyosh_prelineblend( bitmap_rgb32 &bitmap, const rectangle &cliprect );
79   void psikyosh_postlineblend( bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri );
80   void psikyosh_drawgfxzoom( bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
81         UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
82         int alpha, int zoomx, int zoomy, int wide, int high, UINT32 z);   
7083};
trunk/src/mame/includes/pcktgal.h
r20973r20974
1818   virtual void machine_start();
1919   UINT32 screen_update_pcktgal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2020   UINT32 screen_update_pcktgalb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
21   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
2122};
trunk/src/mame/includes/pacman.h
r20973r20974
139139   INTERRUPT_GEN_MEMBER(vblank_irq);
140140   INTERRUPT_GEN_MEMBER(vblank_nmi);
141141   INTERRUPT_GEN_MEMBER(s2650_interrupt);
142   void init_save_state();
143   void jrpacman_mark_tile_dirty( int offset );
144   void maketrax_rom_decode();
145   void korosuke_rom_decode();
146   void eyes_decode(UINT8 *data);
147   void mspacman_install_patches(UINT8 *ROM);
142148};
143149
144150/*----------- defined in machine/pacplus.c -----------*/
trunk/src/mame/includes/pooyan.h
r20973r20974
3434   virtual void palette_init();
3535   UINT32 screen_update_pooyan(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3636   INTERRUPT_GEN_MEMBER(pooyan_interrupt);
37   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
3738};
trunk/src/mame/includes/pandoras.h
r20973r20974
5353   UINT32 screen_update_pandoras(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5454   INTERRUPT_GEN_MEMBER(pandoras_master_interrupt);
5555   INTERRUPT_GEN_MEMBER(pandoras_slave_interrupt);
56   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* sr );
5657};
trunk/src/mame/includes/pirates.h
r20973r20974
3030   TILE_GET_INFO_MEMBER(get_bg_tile_info);
3131   virtual void video_start();
3232   UINT32 screen_update_pirates(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
33   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
34   void pirates_decrypt_68k();
35   void pirates_decrypt_p();
36   void pirates_decrypt_s();
37   void pirates_decrypt_oki();
3338};
trunk/src/mame/includes/policetr.h
r20973r20974
4949   UINT32 screen_update_policetr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   INTERRUPT_GEN_MEMBER(irq4_gen);
5151   TIMER_CALLBACK_MEMBER(irq5_gen);
52   void render_display_list(offs_t offset);
5253};
trunk/src/mame/video/policetr.c
r20973r20974
4242 *
4343 *************************************/
4444
45static void render_display_list(running_machine &machine, offs_t offset)
45void policetr_state::render_display_list(offs_t offset)
4646{
47   policetr_state *state = machine.driver_data<policetr_state>();
4847   /* mask against the R3000 address space */
4948   offset &= 0x1fffffff;
5049
5150   /* loop over all items */
5251   while (offset != 0x1fffffff)
5352   {
54      UINT32 *entry = &state->m_rambase[offset / 4];
53      UINT32 *entry = &m_rambase[offset / 4];
5554      UINT32 srcx = entry[0] & 0xfffffff;
56      UINT32 srcy = entry[1] & ((state->m_srcbitmap_height_mask << 16) | 0xffff);
55      UINT32 srcy = entry[1] & ((m_srcbitmap_height_mask << 16) | 0xffff);
5756      UINT32 srcxstep = entry[2];
5857      UINT32 srcystep = entry[3];
5958      int dstw = (entry[4] & 0x1ff) + 1;
r20973r20974
6564      UINT32 curx, cury;
6665      int x, y;
6766
68      if (dstx > state->m_render_clip.max_x)
67      if (dstx > m_render_clip.max_x)
6968      {
7069         dstw -= (512 - dstx);
7170         dstx = 0;
7271      }
7372      /* apply X clipping */
74      if (dstx < state->m_render_clip.min_x)
73      if (dstx < m_render_clip.min_x)
7574      {
76         srcx += srcxstep * (state->m_render_clip.min_x - dstx);
77         dstw -= state->m_render_clip.min_x - dstx;
78         dstx = state->m_render_clip.min_x;
75         srcx += srcxstep * (m_render_clip.min_x - dstx);
76         dstw -= m_render_clip.min_x - dstx;
77         dstx = m_render_clip.min_x;
7978      }
80      if (dstx + dstw > state->m_render_clip.max_x)
81         dstw = state->m_render_clip.max_x - dstx + 1;
79      if (dstx + dstw > m_render_clip.max_x)
80         dstw = m_render_clip.max_x - dstx + 1;
8281
8382      /* apply Y clipping */
84      if (dsty < state->m_render_clip.min_y)
83      if (dsty < m_render_clip.min_y)
8584      {
86         srcy += srcystep * (state->m_render_clip.min_y - dsty);
87         dsth -= state->m_render_clip.min_y - dsty;
88         dsty = state->m_render_clip.min_y;
85         srcy += srcystep * (m_render_clip.min_y - dsty);
86         dsth -= m_render_clip.min_y - dsty;
87         dsty = m_render_clip.min_y;
8988      }
90      if (dsty + dsth > state->m_render_clip.max_y)
91         dsth = state->m_render_clip.max_y - dsty + 1;
89      if (dsty + dsth > m_render_clip.max_y)
90         dsth = m_render_clip.max_y - dsty + 1;
9291
9392      /* special case for fills */
9493      if (srcxstep == 0 && srcystep == 0)
9594      {
9695         /* prefetch the pixel */
97         UINT8 pixel = state->m_srcbitmap[((srcy >> 16) * state->m_srcbitmap_height_mask) * SRCBITMAP_WIDTH + (srcx >> 16) % SRCBITMAP_WIDTH];
96         UINT8 pixel = m_srcbitmap[((srcy >> 16) * m_srcbitmap_height_mask) * SRCBITMAP_WIDTH + (srcx >> 16) % SRCBITMAP_WIDTH];
9897         pixel = color | (pixel & mask);
9998
10099         /* loop over rows and columns */
101100         if (dstw > 0)
102101            for (y = 0; y < dsth; y++)
103102            {
104               UINT8 *dst = &state->m_dstbitmap[(dsty + y) * DSTBITMAP_WIDTH + dstx];
103               UINT8 *dst = &m_dstbitmap[(dsty + y) * DSTBITMAP_WIDTH + dstx];
105104               memset(dst, pixel, dstw);
106105            }
107106      }
r20973r20974
112111         /* loop over rows */
113112         for (y = 0, cury = srcy; y < dsth; y++, cury += srcystep)
114113         {
115            UINT8 *src = &state->m_srcbitmap[((cury >> 16) & state->m_srcbitmap_height_mask) * SRCBITMAP_WIDTH];
116            UINT8 *dst = &state->m_dstbitmap[(dsty + y) * DSTBITMAP_WIDTH + dstx];
114            UINT8 *src = &m_srcbitmap[((cury >> 16) & m_srcbitmap_height_mask) * SRCBITMAP_WIDTH];
115            UINT8 *dst = &m_dstbitmap[(dsty + y) * DSTBITMAP_WIDTH + dstx];
117116
118117            /* loop over columns */
119118            for (x = 0, curx = srcx; x < dstw; x++, curx += srcxstep)
r20973r20974
149148   {
150149      /* offset 0 specifies the start address of a display list */
151150      case 0:
152         render_display_list(machine(), data);
151         render_display_list(data);
153152         break;
154153
155154      /* offset 1 specifies a latch value in the upper 8 bits */
trunk/src/mame/video/pacland.c
r20973r20974
5555
5656***************************************************************************/
5757
58static void switch_palette(running_machine &machine)
58void pacland_state::switch_palette()
5959{
60   pacland_state *state = machine.driver_data<pacland_state>();
6160   int i;
62   const UINT8 *color_prom = state->m_color_prom + 256 * state->m_palette_bank;
61   const UINT8 *color_prom = m_color_prom + 256 * m_palette_bank;
6362
6463   for (i = 0;i < 256;i++)
6564   {
r20973r20974
8483
8584      color_prom++;
8685
87      colortable_palette_set_color(machine.colortable,i,MAKE_RGB(r,g,b));
86      colortable_palette_set_color(machine().colortable,i,MAKE_RGB(r,g,b));
8887   }
8988}
9089
r20973r20974
113112      colortable_entry_set_value(machine().colortable, machine().gfx[2]->colorbase() + i, *color_prom++);
114113
115114   m_palette_bank = 0;
116   switch_palette(machine());
115   switch_palette();
117116
118117   /* precalculate transparency masks for sprites */
119118   m_transmask[0] = auto_alloc_array(machine(), UINT32, 64);
r20973r20974
259258   if (m_palette_bank != ((data & 0x18) >> 3))
260259   {
261260      m_palette_bank = (data & 0x18) >> 3;
262      switch_palette(machine());
261      switch_palette();
263262   }
264263}
265264
r20973r20974
272271***************************************************************************/
273272
274273/* the sprite generator IC is the same as Mappy */
275static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int whichmask)
274void pacland_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int whichmask)
276275{
277   pacland_state *state = machine.driver_data<pacland_state>();
278   UINT8 *spriteram = state->m_spriteram + 0x780;
276   UINT8 *spriteram = m_spriteram + 0x780;
279277   UINT8 *spriteram_2 = spriteram + 0x800;
280278   UINT8 *spriteram_3 = spriteram_2 + 0x800;
281279   int offs;
r20973r20974
300298      sprite &= ~sizex;
301299      sprite &= ~(sizey << 1);
302300
303      if (state->flip_screen())
301      if (flip_screen())
304302      {
305303         flipx ^= 1;
306304         flipy ^= 1;
r20973r20974
314312         for (x = 0;x <= sizex;x++)
315313         {
316314            if (whichmask != 0)
317               drawgfx_transmask(bitmap,cliprect,machine.gfx[2],
315               drawgfx_transmask(bitmap,cliprect,machine().gfx[2],
318316                  sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)],
319317                  color,
320318                  flipx,flipy,
321                  sx + 16*x,sy + 16*y,state->m_transmask[whichmask][color]);
319                  sx + 16*x,sy + 16*y,m_transmask[whichmask][color]);
322320            else
323               pdrawgfx_transmask(bitmap,cliprect,machine.gfx[2],
321               pdrawgfx_transmask(bitmap,cliprect,machine().gfx[2],
324322                  sprite + gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)],
325323                  color,
326324                  flipx,flipy,
327325                  sx + 16*x,sy + 16*y,
328                  machine.priority_bitmap,0,state->m_transmask[whichmask][color]);
326                  machine().priority_bitmap,0,m_transmask[whichmask][color]);
329327         }
330328      }
331329   }
332330}
333331
334332
335static void draw_fg(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
333void pacland_state::draw_fg(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
336334{
337   pacland_state *state = machine.driver_data<pacland_state>();
338335   int y, x;
339336
340337   /* draw tilemap transparently over it; this will leave invalid pens (0xffff)
341338      anywhere where the fg_tilemap should be transparent; note that we assume
342339      the fg_bitmap has been pre-erased to 0xffff */
343   state->m_fg_tilemap->draw(state->m_fg_bitmap, cliprect, priority, 0);
340   m_fg_tilemap->draw(m_fg_bitmap, cliprect, priority, 0);
344341
345342   /* now copy the fg_bitmap to the destination wherever the sprite pixel allows */
346343   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
347344   {
348      const UINT8 *pri = &machine.priority_bitmap.pix8(y);
349      UINT16 *src = &state->m_fg_bitmap.pix16(y);
345      const UINT8 *pri = &machine().priority_bitmap.pix8(y);
346      UINT16 *src = &m_fg_bitmap.pix16(y);
350347      UINT16 *dst = &bitmap.pix16(y);
351348
352349      /* only copy if the priority bitmap is 0 (no high priority sprite) and the
r20973r20974
377374      wherever there is a high-priority pixel; note that we draw to the bitmap
378375      which is safe because the bg_tilemap draw will overwrite everything */
379376   machine().priority_bitmap.fill(0x00, cliprect);
380   draw_sprites(machine(), bitmap, cliprect, 0);
377   draw_sprites(bitmap, cliprect, 0);
381378
382379   /* draw background */
383380   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
384381
385382   /* draw low priority fg tiles */
386   draw_fg(machine(), bitmap, cliprect, 0);
383   draw_fg(bitmap, cliprect, 0);
387384
388385   /* draw sprites with regular transparency */
389   draw_sprites(machine(), bitmap, cliprect, 1);
386   draw_sprites(bitmap, cliprect, 1);
390387
391388   /* draw high priority fg tiles */
392   draw_fg(machine(), bitmap, cliprect, 1);
389   draw_fg(bitmap, cliprect, 1);
393390
394391   /* draw sprite pixels with colortable values >= 0xf0, which have priority over everything */
395   draw_sprites(machine(), bitmap, cliprect, 2);
392   draw_sprites(bitmap, cliprect, 2);
396393   return 0;
397394}
trunk/src/mame/video/psikyo4.c
r20973r20974
3131
3232
3333/* --- SPRITES --- */
34static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 scr )
34void psikyo4_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 scr )
3535{
3636   /*- Sprite Format 0x0000 - 0x2bff -**
3737
r20973r20974
5252
5353   **- End Sprite Format -*/
5454
55   psikyo4_state *state = machine.driver_data<psikyo4_state>();
56   gfx_element *gfx = machine.gfx[0];
57   UINT32 *source = state->m_spriteram;
58   UINT16 *list = (UINT16 *)state->m_spriteram.target() + 0x2c00/2 + 0x04/2; /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */
55   gfx_element *gfx = machine().gfx[0];
56   UINT32 *source = m_spriteram;
57   UINT16 *list = (UINT16 *)m_spriteram.target() + 0x2c00/2 + 0x04/2; /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */
5958   UINT16 listlen = (0xc00/2 - 0x04/2), listcntr = 0;
6059   int flipscreen1, flipscreen2;
6160
62   flipscreen1 = (((state->m_vidregs[1] >> 30) & 2) == 2) ? 1 : 0;
63   flipscreen2 = (((state->m_vidregs[1] >> 22) & 2) == 2) ? 1 : 0;
61   flipscreen1 = (((m_vidregs[1] >> 30) & 2) == 2) ? 1 : 0;
62   flipscreen2 = (((m_vidregs[1] >> 22) & 2) == 2) ? 1 : 0;
6463
6564   while (listcntr < listlen)
6665   {
r20973r20974
9998
10099         if ((!scr && flipscreen1) || (scr && flipscreen2))
101100         {
102            ypos = machine.primary_screen->visible_area().max_y + 1 - ypos - high * 16; /* Screen Height depends on game */
101            ypos = machine().primary_screen->visible_area().max_y + 1 - ypos - high * 16; /* Screen Height depends on game */
103102            xpos = 40 * 8 - xpos - wide * 16;
104103            flipx = !flipx;
105104            flipy = !flipy;
r20973r20974
130129UINT32 psikyo4_state::screen_update_psikyo4_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
131130{
132131   bitmap.fill(0x1000, cliprect);
133   draw_sprites(machine(), bitmap, cliprect, 0x0000);
132   draw_sprites(bitmap, cliprect, 0x0000);
134133   return 0;
135134}
136135
137136UINT32 psikyo4_state::screen_update_psikyo4_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
138137{
139138   bitmap.fill(0x1001, cliprect);
140   draw_sprites(machine(), bitmap, cliprect, 0x2000);
139   draw_sprites(bitmap, cliprect, 0x2000);
141140   return 0;
142141}
143142
trunk/src/mame/video/powerins.c
r20973r20974
248248#define SIGN_EXTEND_POS(_var_)  {_var_ &= 0x3ff; if (_var_ > 0x1ff) _var_ -= 0x400;}
249249
250250
251static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
251void powerins_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
252252{
253   powerins_state *state = machine.driver_data<powerins_state>();
254   UINT16 *source = state->m_spriteram + 0x8000/2;
255   UINT16 *finish = state->m_spriteram + 0x9000/2;
253   UINT16 *source = m_spriteram + 0x8000/2;
254   UINT16 *finish = m_spriteram + 0x9000/2;
256255
257   int screen_w = machine.primary_screen->width();
258   int screen_h = machine.primary_screen->height();
256   int screen_w = machine().primary_screen->width();
257   int screen_h = machine().primary_screen->height();
259258
260259   for ( ; source < finish; source += 16/2 )
261260   {
r20973r20974
281280
282281      /* Handle flip_screen. Apply a global offset of 32 pixels along x too */
283282
284      if (state->flip_screen())
283      if (flip_screen())
285284      {
286285         sx = screen_w - sx - dimx*16 - 32;  flipx = !flipx;
287286         sy = screen_h - sy - dimy*16;       flipy = !flipy;
r20973r20974
298297      {
299298         for (y = 0 ; y < dimy ; y++)
300299         {
301            drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
300            drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
302301                  code,
303302                  color,
304303                  flipx, flipy,
r20973r20974
353352
354353   if (layers_ctrl&1)      m_tilemap_0->draw(bitmap, cliprect, 0, 0);
355354   else                    bitmap.fill(0, cliprect);
356   if (layers_ctrl&8)      draw_sprites(machine(),bitmap,cliprect);
355   if (layers_ctrl&8)      draw_sprites(bitmap,cliprect);
357356   if (layers_ctrl&2)      m_tilemap_1->draw(bitmap, cliprect, 0, 0);
358357   return 0;
359358}
trunk/src/mame/video/paradise.c
r20973r20974
3939}
4040
4141/* Note: Penky updates pixel palette bank register BEFORE actually writing to the paletteram. */
42static void update_pix_palbank(running_machine &machine)
42void paradise_state::update_pix_palbank()
4343{
44   paradise_state *state = machine.driver_data<paradise_state>();
4544   int i;
4645
4746   for (i = 0; i < 15; i++)
48      palette_set_color_rgb(machine, 0x800 + i, state->m_paletteram[0x200 + state->m_pixbank + i + 0x800 * 0], state->m_paletteram[0x200 + state->m_pixbank + i + 0x800 * 1],
49                        state->m_paletteram[0x200 + state->m_pixbank + i + 0x800 * 2]);
47      palette_set_color_rgb(machine(), 0x800 + i, m_paletteram[0x200 + m_pixbank + i + 0x800 * 0], m_paletteram[0x200 + m_pixbank + i + 0x800 * 1],
48                        m_paletteram[0x200 + m_pixbank + i + 0x800 * 2]);
5049}
5150
5251/* 800 bytes for red, followed by 800 bytes for green & 800 bytes for blue */
r20973r20974
5756   palette_set_color_rgb(machine(), offset, m_paletteram[offset + 0x800 * 0], m_paletteram[offset + 0x800 * 1],
5857      m_paletteram[offset + 0x800 * 2]);
5958
60   update_pix_palbank(machine());
59   update_pix_palbank();
6160}
6261
6362/***************************************************************************
r20973r20974
8685
8786   m_pixbank = bank2;
8887
89   update_pix_palbank(machine());
88   update_pix_palbank();
9089
9190   if (m_palbank != bank1)
9291   {
r20973r20974
180179   m_priority = data;
181180}
182181
183static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
182void paradise_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
184183{
185   paradise_state *state = machine.driver_data<paradise_state>();
186   UINT8 *spriteram = state->m_spriteram;
184   UINT8 *spriteram = m_spriteram;
187185   int i;
188   for (i = 0; i < state->m_spriteram.bytes() ; i += state->m_sprite_inc)
186   for (i = 0; i < m_spriteram.bytes() ; i += m_sprite_inc)
189187   {
190188      int code = spriteram[i + 0];
191189      int x    = spriteram[i + 1];
r20973r20974
195193      int flipx = 0;  // ?
196194      int flipy = 0;
197195
198      if (state->flip_screen())
196      if (flip_screen())
199197      {
200198         x = 0xf0 - x;   flipx = !flipx;
201199         y = 0xf0 - y;   flipy = !flipy;
202200      }
203201
204      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
202      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
205203            code + (attr << 8),
206204            0,
207205            flipx, flipy,
208206            x,y, 0xff );
209207
210208      /* wrap around x */
211      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
209      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
212210            code + (attr << 8),
213211            0,
214212            flipx, flipy,
215213            x - 256,y, 0xff );
216214
217      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
215      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
218216            code + (attr << 8),
219217            0,
220218            flipx, flipy,
r20973r20974
253251
254252   if (m_priority & 1)
255253      if (layers_ctrl & 16)
256         draw_sprites(screen.machine(), bitmap, cliprect);
254         draw_sprites(bitmap, cliprect);
257255
258256   if (layers_ctrl & 1)    m_tilemap_0->draw(bitmap, cliprect, 0, 0);
259257   if (layers_ctrl & 2)    m_tilemap_1->draw(bitmap, cliprect, 0, 0);
r20973r20974
263261   {
264262      if (!(m_priority & 1))
265263         if (layers_ctrl & 16)
266            draw_sprites(screen.machine(), bitmap, cliprect);
264            draw_sprites(bitmap, cliprect);
267265      if (layers_ctrl & 8)
268266         m_tilemap_2->draw(bitmap, cliprect, 0, 0);
269267   }
r20973r20974
273271         m_tilemap_2->draw(bitmap, cliprect, 0, 0);
274272      if (!(m_priority & 1))
275273         if (layers_ctrl & 16)
276            draw_sprites(screen.machine(), bitmap, cliprect);
274            draw_sprites(bitmap, cliprect);
277275   }
278276   return 0;
279277}
r20973r20974
287285      return 0;
288286
289287   if (m_priority & 1)
290      draw_sprites(machine(), bitmap, cliprect);
288      draw_sprites(bitmap, cliprect);
291289
292290   m_tilemap_1->draw(bitmap, cliprect, 0,0);
293291
294292   if (m_priority & 4)
295293   {
296294      if (!(m_priority & 1))
297         draw_sprites(machine(), bitmap, cliprect);
295         draw_sprites(bitmap, cliprect);
298296
299297      m_tilemap_2->draw(bitmap, cliprect, 0, 0);
300298   }
r20973r20974
303301      m_tilemap_2->draw(bitmap, cliprect, 0, 0);
304302
305303      if (!(m_priority & 1))
306         draw_sprites(machine(), bitmap,cliprect);
304         draw_sprites(bitmap,cliprect);
307305   }
308306   return 0;
309307}
r20973r20974
315313   m_tilemap_0->draw(bitmap, cliprect, 0, 0);
316314   m_tilemap_1->draw(bitmap, cliprect, 0, 0);
317315   m_tilemap_2->draw(bitmap, cliprect, 0, 0);
318   draw_sprites(machine(), bitmap, cliprect);
316   draw_sprites(bitmap, cliprect);
319317   return 0;
320318}
trunk/src/mame/video/punchout.c
r20973r20974
187187
188188
189189
190static void draw_big_sprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int palette)
190void punchout_state::draw_big_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int palette)
191191{
192   punchout_state *state = machine.driver_data<punchout_state>();
193192   int zoom;
194193
195   zoom = state->m_spr1_ctrlram[0] + 256 * (state->m_spr1_ctrlram[1] & 0x0f);
194   zoom = m_spr1_ctrlram[0] + 256 * (m_spr1_ctrlram[1] & 0x0f);
196195   if (zoom)
197196   {
198197      int sx,sy;
199198      UINT32 startx,starty;
200199      int incxx,incyy;
201200
202      sx = 4096 - (state->m_spr1_ctrlram[2] + 256 * (state->m_spr1_ctrlram[3] & 0x0f));
201      sx = 4096 - (m_spr1_ctrlram[2] + 256 * (m_spr1_ctrlram[3] & 0x0f));
203202      if (sx > 4096-4*127) sx -= 4096;
204203
205      sy = -(state->m_spr1_ctrlram[4] + 256 * (state->m_spr1_ctrlram[5] & 1));
204      sy = -(m_spr1_ctrlram[4] + 256 * (m_spr1_ctrlram[5] & 1));
206205      if (sy <= -256 + zoom/0x40) sy += 512;
207206      sy += 12;
208207
r20973r20974
214213      startx += 3740 * zoom;  /* adjustment to match the screen shots */
215214      starty -= 178 * zoom;   /* and make the hall of fame picture nice */
216215
217      if (state->m_spr1_ctrlram[6] & 1)   /* flip x */
216      if (m_spr1_ctrlram[6] & 1)   /* flip x */
218217      {
219218         startx = ((16 * 8) << 16) - startx - 1;
220219         incxx = -incxx;
221220      }
222221
223      state->m_spr1_tilemap->set_palette_offset(0x100 * palette);
222      m_spr1_tilemap->set_palette_offset(0x100 * palette);
224223
225      state->m_spr1_tilemap->draw_roz(bitmap, cliprect,
224      m_spr1_tilemap->draw_roz(bitmap, cliprect,
226225         startx,starty + 0x200*(2) * zoom,
227226         incxx,0,0,incyy,    /* zoom, no rotation */
228227         0,  /* no wraparound */
r20973r20974
231230}
232231
233232
234static void armwrest_draw_big_sprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int palette)
233void punchout_state::armwrest_draw_big_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect, int palette)
235234{
236   punchout_state *state = machine.driver_data<punchout_state>();
237235   int zoom;
238236
239   zoom = state->m_spr1_ctrlram[0] + 256 * (state->m_spr1_ctrlram[1] & 0x0f);
237   zoom = m_spr1_ctrlram[0] + 256 * (m_spr1_ctrlram[1] & 0x0f);
240238   if (zoom)
241239   {
242240      int sx,sy;
r20973r20974
244242      int incxx,incyy;
245243      tilemap_t *_tilemap;
246244
247      sx = 4096 - (state->m_spr1_ctrlram[2] + 256 * (state->m_spr1_ctrlram[3] & 0x0f));
245      sx = 4096 - (m_spr1_ctrlram[2] + 256 * (m_spr1_ctrlram[3] & 0x0f));
248246      if (sx > 2048) sx -= 4096;
249247
250      sy = -(state->m_spr1_ctrlram[4] + 256 * (state->m_spr1_ctrlram[5] & 1));
248      sy = -(m_spr1_ctrlram[4] + 256 * (m_spr1_ctrlram[5] & 1));
251249      if (sy <= -256 + zoom/0x40) sy += 512;
252250      sy += 12;
253251
r20973r20974
259257      startx += 3740 * zoom;  /* adjustment to match the screen shots */
260258      starty -= 178 * zoom;   /* and make the hall of fame picture nice */
261259
262      if (state->m_spr1_ctrlram[6] & 1)   /* flip x */
260      if (m_spr1_ctrlram[6] & 1)   /* flip x */
263261      {
264         _tilemap = state->m_spr1_tilemap_flipx;
262         _tilemap = m_spr1_tilemap_flipx;
265263         startx = ((32 * 8) << 16) - startx - 1;
266264         incxx = -incxx;
267265      }
268266      else
269         _tilemap = state->m_spr1_tilemap;
267         _tilemap = m_spr1_tilemap;
270268
271269      _tilemap->set_palette_offset(0x100 * palette);
272270
r20973r20974
278276   }
279277}
280278
281static void drawbs2(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
279void punchout_state::drawbs2(bitmap_ind16 &bitmap, const rectangle &cliprect)
282280{
283   punchout_state *state = machine.driver_data<punchout_state>();
284281   int sx,sy;
285282   int incxx;
286283
287   sx = 512 - (state->m_spr2_ctrlram[0] + 256 * (state->m_spr2_ctrlram[1] & 1));
284   sx = 512 - (m_spr2_ctrlram[0] + 256 * (m_spr2_ctrlram[1] & 1));
288285   if (sx > 512-127) sx -= 512;
289286   sx -= 55;   /* adjustment to match the screen shots */
290287
291   sy = -state->m_spr2_ctrlram[2] + 256 * (state->m_spr2_ctrlram[3] & 1);
288   sy = -m_spr2_ctrlram[2] + 256 * (m_spr2_ctrlram[3] & 1);
292289   sy += 3;    /* adjustment to match the screen shots */
293290
294291   sx = -sx << 16;
295292   sy = -sy << 16;
296293
297   if (state->m_spr2_ctrlram[4] & 1)   /* flip x */
294   if (m_spr2_ctrlram[4] & 1)   /* flip x */
298295   {
299296      sx = ((16 * 8) << 16) - sx - 1;
300297      incxx = -1;
r20973r20974
303300      incxx = 1;
304301
305302   // this tilemap doesn't actually zoom, but draw_roz is the only way to draw it without wraparound
306   state->m_spr2_tilemap->draw_roz(bitmap, cliprect,
303   m_spr2_tilemap->draw_roz(bitmap, cliprect,
307304      sx, sy, incxx << 16, 0, 0, 1 << 16,
308305      0, 0, 0);
309306}
310307
311308
312309
313static void punchout_copy_top_palette(running_machine &machine, int bank)
310void punchout_state::punchout_copy_top_palette(int bank)
314311{
315   punchout_state *state = machine.driver_data<punchout_state>();
316312   int i;
317   const UINT8 *color_prom = state->memregion("proms")->base();
313   const UINT8 *color_prom = memregion("proms")->base();
318314
319315   // top monitor palette
320316   for (i = 0; i < 0x100; i++)
r20973r20974
326322      g = 255 - pal4bit(color_prom[i + 0x200 + base]);
327323      b = 255 - pal4bit(color_prom[i + 0x400 + base]);
328324
329      palette_set_color(machine, i ^ state->m_palette_reverse_top, MAKE_RGB(r, g, b));
325      palette_set_color(machine(), i ^ m_palette_reverse_top, MAKE_RGB(r, g, b));
330326   }
331327}
332328
333static void punchout_copy_bot_palette(running_machine &machine, int bank)
329void punchout_state::punchout_copy_bot_palette(int bank)
334330{
335   punchout_state *state = machine.driver_data<punchout_state>();
336331   int i;
337   const UINT8 *color_prom = state->memregion("proms")->base() + 0x600;
332   const UINT8 *color_prom = memregion("proms")->base() + 0x600;
338333
339334   // bottom monitor palette
340335   for (i = 0; i < 0x100; i++)
r20973r20974
346341      g = 255 - pal4bit(color_prom[i + 0x200 + base]);
347342      b = 255 - pal4bit(color_prom[i + 0x400 + base]);
348343
349      palette_set_color(machine, (i ^ state->m_palette_reverse_bot) + 0x100, MAKE_RGB(r, g, b));
344      palette_set_color(machine(), (i ^ m_palette_reverse_bot) + 0x100, MAKE_RGB(r, g, b));
350345   }
351346}
352347
353348
354349UINT32 punchout_state::screen_update_punchout_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
355350{
356   punchout_copy_top_palette(machine(), BIT(*m_palettebank,1));
351   punchout_copy_top_palette(BIT(*m_palettebank,1));
357352
358353   m_bg_top_tilemap->draw(bitmap, cliprect, 0, 0);
359354
360355   if (m_spr1_ctrlram[7] & 1)  /* display in top monitor */
361      draw_big_sprite(machine(), bitmap, cliprect, 0);
356      draw_big_sprite(bitmap, cliprect, 0);
362357
363358   return 0;
364359}
r20973r20974
367362{
368363   int offs;
369364
370   punchout_copy_bot_palette(machine(), BIT(*m_palettebank,0));
365   punchout_copy_bot_palette(BIT(*m_palettebank,0));
371366
372367   /* copy the character mapped graphics */
373368   for (offs = 0;offs < 32;offs++)
r20973r20974
376371   m_bg_bot_tilemap->draw(bitmap, cliprect, 0, 0);
377372
378373   if (m_spr1_ctrlram[7] & 2)  /* display in bottom monitor */
379      draw_big_sprite(machine(), bitmap, cliprect, 1);
380   drawbs2(machine(), bitmap, cliprect);
374      draw_big_sprite(bitmap, cliprect, 1);
375   drawbs2(bitmap, cliprect);
381376
382377   return 0;
383378}
r20973r20974
385380
386381UINT32 punchout_state::screen_update_armwrest_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
387382{
388   punchout_copy_top_palette(machine(), BIT(*m_palettebank,1));
383   punchout_copy_top_palette(BIT(*m_palettebank,1));
389384
390385   m_bg_top_tilemap->draw(bitmap, cliprect, 0, 0);
391386
392387   if (m_spr1_ctrlram[7] & 1)  /* display in top monitor */
393      armwrest_draw_big_sprite(machine(), bitmap, cliprect, 0);
388      armwrest_draw_big_sprite(bitmap, cliprect, 0);
394389
395390   return 0;
396391}
397392
398393UINT32 punchout_state::screen_update_armwrest_bottom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
399394{
400   punchout_copy_bot_palette(machine(), BIT(*m_palettebank,0));
395   punchout_copy_bot_palette(BIT(*m_palettebank,0));
401396
402397   m_bg_bot_tilemap->draw(bitmap, cliprect, 0, 0);
403398
404399   if (m_spr1_ctrlram[7] & 2)  /* display in bottom monitor */
405      armwrest_draw_big_sprite(machine(), bitmap, cliprect, 1);
406   drawbs2(machine(), bitmap, cliprect);
400      armwrest_draw_big_sprite(bitmap, cliprect, 1);
401   drawbs2(bitmap, cliprect);
407402
408403   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
409404
trunk/src/mame/video/prehisle.c
r20973r20974
117117
1181183 xxxx............ color+priority, other bits unknown
119119*/
120static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int foreground )
120void prehisle_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int foreground )
121121{
122   prehisle_state *state = machine.driver_data<prehisle_state>();
123   UINT16 *spriteram16 = state->m_spriteram;
122   UINT16 *spriteram16 = m_spriteram;
124123   int offs;
125124
126125   for (offs = 0; offs < 1024; offs += 4)
r20973r20974
138137      if (sx&0x100) sx=-0x100+(sx&0xff);
139138      if (sy&0x100) sy=-0x100+(sy&0xff);
140139
141      if (state->flip_screen())
140      if (flip_screen())
142141      {
143142         sx = 240 - sx;
144143         sy = 240 - sy;
r20973r20974
148147
149148      if ((foreground && priority) || (!foreground && !priority))
150149      {
151         drawgfx_transpen(bitmap, cliprect, machine.gfx[3], code, color, flipx, flipy, sx, sy, 15);
150         drawgfx_transpen(bitmap, cliprect, machine().gfx[3], code, color, flipx, flipy, sx, sy, 15);
152151      }
153152   }
154153}
r20973r20974
156155UINT32 prehisle_state::screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
157156{
158157   m_bg2_tilemap->draw(bitmap, cliprect, 0, 0);
159   draw_sprites(machine(), bitmap, cliprect, 0);
158   draw_sprites(bitmap, cliprect, 0);
160159   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
161   draw_sprites(machine(), bitmap, cliprect, 1);
160   draw_sprites(bitmap, cliprect, 1);
162161   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
163162   return 0;
164163}
trunk/src/mame/video/popeye.c
r20973r20974
4949  The bootleg is the same, but the outputs are not inverted.
5050
5151***************************************************************************/
52static void convert_color_prom(running_machine &machine,const UINT8 *color_prom)
52void popeye_state::convert_color_prom(const UINT8 *color_prom)
5353{
54   popeye_state *state = machine.driver_data<popeye_state>();
5554   int i;
5655
5756
r20973r20974
6564      int bit0,bit1,bit2,r,g,b;
6665
6766      /* red component */
68      bit0 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 0) & 0x01;
69      bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 1) & 0x01;
70      bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 2) & 0x01;
67      bit0 = ((color_prom[prom_offs] ^ m_invertmask) >> 0) & 0x01;
68      bit1 = ((color_prom[prom_offs] ^ m_invertmask) >> 1) & 0x01;
69      bit2 = ((color_prom[prom_offs] ^ m_invertmask) >> 2) & 0x01;
7170      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
7271      /* green component */
73      bit0 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 3) & 0x01;
74      bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 4) & 0x01;
75      bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 5) & 0x01;
72      bit0 = ((color_prom[prom_offs] ^ m_invertmask) >> 3) & 0x01;
73      bit1 = ((color_prom[prom_offs] ^ m_invertmask) >> 4) & 0x01;
74      bit2 = ((color_prom[prom_offs] ^ m_invertmask) >> 5) & 0x01;
7675      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
7776      /* blue component */
7877      bit0 = 0;
79      bit1 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 6) & 0x01;
80      bit2 = ((color_prom[prom_offs] ^ state->m_invertmask) >> 7) & 0x01;
78      bit1 = ((color_prom[prom_offs] ^ m_invertmask) >> 6) & 0x01;
79      bit2 = ((color_prom[prom_offs] ^ m_invertmask) >> 7) & 0x01;
8180      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
8281
83      palette_set_color(machine,16 + (2 * i) + 1,MAKE_RGB(r,g,b));
82      palette_set_color(machine(),16 + (2 * i) + 1,MAKE_RGB(r,g,b));
8483   }
8584
8685   color_prom += 32;
r20973r20974
9291
9392
9493      /* red component */
95      bit0 = ((color_prom[0] ^ state->m_invertmask) >> 0) & 0x01;
96      bit1 = ((color_prom[0] ^ state->m_invertmask) >> 1) & 0x01;
97      bit2 = ((color_prom[0] ^ state->m_invertmask) >> 2) & 0x01;
94      bit0 = ((color_prom[0] ^ m_invertmask) >> 0) & 0x01;
95      bit1 = ((color_prom[0] ^ m_invertmask) >> 1) & 0x01;
96      bit2 = ((color_prom[0] ^ m_invertmask) >> 2) & 0x01;
9897      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
9998      /* green component */
100      bit0 = ((color_prom[0] ^ state->m_invertmask) >> 3) & 0x01;
101      bit1 = ((color_prom[256] ^ state->m_invertmask) >> 0) & 0x01;
102      bit2 = ((color_prom[256] ^ state->m_invertmask) >> 1) & 0x01;
99      bit0 = ((color_prom[0] ^ m_invertmask) >> 3) & 0x01;
100      bit1 = ((color_prom[256] ^ m_invertmask) >> 0) & 0x01;
101      bit2 = ((color_prom[256] ^ m_invertmask) >> 1) & 0x01;
103102      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
104103      /* blue component */
105104      bit0 = 0;
106      bit1 = ((color_prom[256] ^ state->m_invertmask) >> 2) & 0x01;
107      bit2 = ((color_prom[256] ^ state->m_invertmask) >> 3) & 0x01;
105      bit1 = ((color_prom[256] ^ m_invertmask) >> 2) & 0x01;
106      bit2 = ((color_prom[256] ^ m_invertmask) >> 3) & 0x01;
108107      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
109108
110      palette_set_color(machine,48+i,MAKE_RGB(r,g,b));
109      palette_set_color(machine(),48+i,MAKE_RGB(r,g,b));
111110
112111      color_prom++;
113112   }
r20973r20974
118117   const UINT8 *color_prom = machine().root_device().memregion("proms")->base();
119118   m_invertmask = 0xff;
120119
121   convert_color_prom(machine(),color_prom);
120   convert_color_prom(color_prom);
122121}
123122
124123PALETTE_INIT_MEMBER(popeye_state,popeyebl)
r20973r20974
126125   const UINT8 *color_prom = machine().root_device().memregion("proms")->base();
127126   m_invertmask = 0x00;
128127
129   convert_color_prom(machine(),color_prom);
128   convert_color_prom(color_prom);
130129}
131130
132static void set_background_palette(running_machine &machine,int bank)
131void popeye_state::set_background_palette(int bank)
133132{
134   popeye_state *state = machine.driver_data<popeye_state>();
135133   int i;
136   UINT8 *color_prom = state->memregion("proms")->base() + 16 * bank;
134   UINT8 *color_prom = memregion("proms")->base() + 16 * bank;
137135
138136   for (i = 0;i < 16;i++)
139137   {
r20973r20974
141139      int r,g,b;
142140
143141      /* red component */
144      bit0 = ((*color_prom ^ state->m_invertmask) >> 0) & 0x01;
145      bit1 = ((*color_prom ^ state->m_invertmask) >> 1) & 0x01;
146      bit2 = ((*color_prom ^ state->m_invertmask) >> 2) & 0x01;
142      bit0 = ((*color_prom ^ m_invertmask) >> 0) & 0x01;
143      bit1 = ((*color_prom ^ m_invertmask) >> 1) & 0x01;
144      bit2 = ((*color_prom ^ m_invertmask) >> 2) & 0x01;
147145      r = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2;
148146      /* green component */
149      bit0 = ((*color_prom ^ state->m_invertmask) >> 3) & 0x01;
150      bit1 = ((*color_prom ^ state->m_invertmask) >> 4) & 0x01;
151      bit2 = ((*color_prom ^ state->m_invertmask) >> 5) & 0x01;
147      bit0 = ((*color_prom ^ m_invertmask) >> 3) & 0x01;
148      bit1 = ((*color_prom ^ m_invertmask) >> 4) & 0x01;
149      bit2 = ((*color_prom ^ m_invertmask) >> 5) & 0x01;
152150      g = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2;
153151      /* blue component */
154152      bit0 = 0;
155      bit1 = ((*color_prom ^ state->m_invertmask) >> 6) & 0x01;
156      bit2 = ((*color_prom ^ state->m_invertmask) >> 7) & 0x01;
157      if (state->m_bitmap_type == TYPE_SKYSKIPR)
153      bit1 = ((*color_prom ^ m_invertmask) >> 6) & 0x01;
154      bit2 = ((*color_prom ^ m_invertmask) >> 7) & 0x01;
155      if (m_bitmap_type == TYPE_SKYSKIPR)
158156      {
159157         /* Sky Skipper has different weights */
160158         bit0 = bit1;
r20973r20974
162160      }
163161      b = 0x1c * bit0 + 0x31 * bit1 + 0x47 * bit2;
164162
165      palette_set_color(machine,i,MAKE_RGB(r,g,b));
163      palette_set_color(machine(),i,MAKE_RGB(r,g,b));
166164
167165      color_prom++;
168166   }
r20973r20974
273271   state_save_register_global_pointer(machine(), m_bitmapram, popeye_bitmapram_size);
274272}
275273
276static void draw_background(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
274void popeye_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
277275{
278   popeye_state *state = machine.driver_data<popeye_state>();
279276   int offs;
280   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
277   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
281278
282   if (state->m_lastflip != state->flip_screen())
279   if (m_lastflip != flip_screen())
283280   {
284281      for (offs = 0;offs < popeye_bitmapram_size;offs++)
285         state->popeye_bitmap_w(space,offs,state->m_bitmapram[offs]);
282         popeye_bitmap_w(space,offs,m_bitmapram[offs]);
286283
287      state->m_lastflip = state->flip_screen();
284      m_lastflip = flip_screen();
288285   }
289286
290   set_background_palette(machine, (*state->m_palettebank & 0x08) >> 3);
287   set_background_palette((*m_palettebank & 0x08) >> 3);
291288
292   if (state->m_background_pos[1] == 0)    /* no background */
289   if (m_background_pos[1] == 0)    /* no background */
293290      bitmap.fill(0, cliprect);
294291   else
295292   {
296293      /* copy the background graphics */
297      int scrollx = 200 - state->m_background_pos[0] - 256*(state->m_background_pos[2]&1); /* ??? */
298      int scrolly = 2 * (256 - state->m_background_pos[1]);
294      int scrollx = 200 - m_background_pos[0] - 256*(m_background_pos[2]&1); /* ??? */
295      int scrolly = 2 * (256 - m_background_pos[1]);
299296
300      if (state->m_bitmap_type == TYPE_SKYSKIPR)
297      if (m_bitmap_type == TYPE_SKYSKIPR)
301298         scrollx = 2*scrollx - 512;
302299
303      if (state->flip_screen())
300      if (flip_screen())
304301      {
305         if (state->m_bitmap_type == TYPE_POPEYE)
302         if (m_bitmap_type == TYPE_POPEYE)
306303            scrollx = -scrollx;
307304         scrolly = -scrolly;
308305      }
309306
310      copyscrollbitmap(bitmap,*state->m_tmpbitmap2,1,&scrollx,1,&scrolly,cliprect);
307      copyscrollbitmap(bitmap,*m_tmpbitmap2,1,&scrollx,1,&scrolly,cliprect);
311308   }
312309}
313310
314static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
311void popeye_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
315312{
316   popeye_state *state = machine.driver_data<popeye_state>();
317   UINT8 *spriteram = state->m_spriteram;
313   UINT8 *spriteram = m_spriteram;
318314   int offs;
319315
320   for (offs = 0;offs < state->m_spriteram.bytes();offs += 4)
316   for (offs = 0;offs < m_spriteram.bytes();offs += 4)
321317   {
322318      int code,color,flipx,flipy,sx,sy;
323319
r20973r20974
335331
336332      code = (spriteram[offs + 2] & 0x7f) + ((spriteram[offs + 3] & 0x10) << 3)
337333                     + ((spriteram[offs + 3] & 0x04) << 6);
338      color = (spriteram[offs + 3] & 0x07) + 8*(*state->m_palettebank & 0x07);
339      if (state->m_bitmap_type == TYPE_SKYSKIPR)
334      color = (spriteram[offs + 3] & 0x07) + 8*(*m_palettebank & 0x07);
335      if (m_bitmap_type == TYPE_SKYSKIPR)
340336      {
341337         /* Two of the PROM address pins are tied together and one is not connected... */
342338         color = (color & 0x0f) | ((color & 0x08) << 1);
r20973r20974
348344      sx = 2*(spriteram[offs])-8;
349345      sy = 2*(256-spriteram[offs + 1]);
350346
351      if (state->flip_screen())
347      if (flip_screen())
352348      {
353349         flipx = !flipx;
354350         flipy = !flipy;
r20973r20974
357353      }
358354
359355      if (spriteram[offs] != 0)
360         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
356         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
361357               code ^ 0x1ff,
362358               color,
363359               flipx,flipy,
r20973r20974
367363
368364UINT32 popeye_state::screen_update_popeye(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
369365{
370   draw_background(machine(), bitmap, cliprect);
371   draw_sprites(machine(), bitmap, cliprect);
366   draw_background(bitmap, cliprect);
367   draw_sprites(bitmap, cliprect);
372368   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
373369   return 0;
374370}
trunk/src/mame/video/psikyo.c
r20973r20974
132132   }
133133}
134134
135void psikyo_switch_banks( running_machine &machine, int tmap, int bank )
135void psikyo_state::psikyo_switch_banks( int tmap, int bank )
136136{
137   psikyo_state *state = machine.driver_data<psikyo_state>();
138137
139   if ((tmap == 0) && (bank != state->m_tilemap_0_bank))
138   if ((tmap == 0) && (bank != m_tilemap_0_bank))
140139   {
141      state->m_tilemap_0_bank = bank;
142      state->m_tilemap_0_size0->mark_all_dirty();
143      state->m_tilemap_0_size1->mark_all_dirty();
144      state->m_tilemap_0_size2->mark_all_dirty();
145      state->m_tilemap_0_size3->mark_all_dirty();
140      m_tilemap_0_bank = bank;
141      m_tilemap_0_size0->mark_all_dirty();
142      m_tilemap_0_size1->mark_all_dirty();
143      m_tilemap_0_size2->mark_all_dirty();
144      m_tilemap_0_size3->mark_all_dirty();
146145   }
147   else if ((tmap == 1) && (bank != state->m_tilemap_1_bank))
146   else if ((tmap == 1) && (bank != m_tilemap_1_bank))
148147   {
149      state->m_tilemap_1_bank = bank;
150      state->m_tilemap_1_size0->mark_all_dirty();
151      state->m_tilemap_1_size1->mark_all_dirty();
152      state->m_tilemap_1_size2->mark_all_dirty();
153      state->m_tilemap_1_size3->mark_all_dirty();
148      m_tilemap_1_bank = bank;
149      m_tilemap_1_size0->mark_all_dirty();
150      m_tilemap_1_size1->mark_all_dirty();
151      m_tilemap_1_size2->mark_all_dirty();
152      m_tilemap_1_size3->mark_all_dirty();
154153   }
155154}
156155
r20973r20974
205204{
206205   VIDEO_START_CALL_MEMBER( psikyo );
207206
208   psikyo_switch_banks(machine(), 0, 0); // sngkace / samuraia don't use banking
209   psikyo_switch_banks(machine(), 1, 1); // They share "gfx2" to save memory on other boards
207   psikyo_switch_banks(0, 0); // sngkace / samuraia don't use banking
208   psikyo_switch_banks(1, 1); // They share "gfx2" to save memory on other boards
210209}
211210
212211
r20973r20974
255254
256255***************************************************************************/
257256
258static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen )
257void psikyo_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen )
259258{
260   psikyo_state *state = machine.driver_data<psikyo_state>();
261259
262260   /* tile layers 0 & 1 have priorities 1 & 2 */
263261   static const int pri[] = { 0, 0xfc, 0xff, 0xff };
264262   int offs;
265   UINT16 *spritelist = (UINT16 *)(state->m_spritebuf2 + 0x1800 / 4);
266   UINT8 *TILES = machine.root_device().memregion("spritelut")->base();    // Sprites LUT
267   int TILES_LEN = machine.root_device().memregion("spritelut")->bytes();
263   UINT16 *spritelist = (UINT16 *)(m_spritebuf2 + 0x1800 / 4);
264   UINT8 *TILES = machine().root_device().memregion("spritelut")->base();    // Sprites LUT
265   int TILES_LEN = machine().root_device().memregion("spritelut")->bytes();
268266
269   int width = machine.primary_screen->width();
270   int height = machine.primary_screen->height();
267   int width = machine().primary_screen->width();
268   int height = machine().primary_screen->height();
271269
272270   /* Exit if sprites are disabled */
273271   if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1)   return;
r20973r20974
295293      sprite = spritelist[BYTE_XOR_BE(offs)];
296294
297295      sprite %= 0x300;
298      source = &state->m_spritebuf2[sprite * 8 / 4];
296      source = &m_spritebuf2[sprite * 8 / 4];
299297
300298      /* Draw this sprite */
301299
r20973r20974
326324      zoomx = 32 - zoomx;
327325      zoomy = 32 - zoomy;
328326
329      if (state->flip_screen())
327      if (flip_screen())
330328      {
331329         x = width  - x - (nx * zoomx) / 2;
332330         y = height - y - (ny * zoomy) / 2;
r20973r20974
347345            int addr = (code * 2) & (TILES_LEN - 1);
348346
349347            if (zoomx == 32 && zoomy == 32)
350               pdrawgfx_transpen(bitmap,cliprect,machine.gfx[0],
348               pdrawgfx_transpen(bitmap,cliprect,machine().gfx[0],
351349                     TILES[addr+1] * 256 + TILES[addr],
352350                     attr >> 8,
353351                     flipx, flipy,
354352                     x + dx * 16, y + dy * 16,
355                     machine.priority_bitmap,
353                     machine().priority_bitmap,
356354                     pri[(attr & 0xc0) >> 6],trans_pen);
357355            else
358               pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
356               pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
359357                        TILES[addr+1] * 256 + TILES[addr],
360358                        attr >> 8,
361359                        flipx, flipy,
362360                        x + (dx * zoomx) / 2, y + (dy * zoomy) / 2,
363361                        zoomx << 11,zoomy << 11,
364                        machine.priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen);
362                        machine().priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen);
365363
366364            code++;
367365         }
r20973r20974
374372// until I work out why it makes a partial copy of the sprite list, and how best to apply it
375373// sprite placement of the explosion graphic seems incorrect compared to the original sets? (no / different zoom support?)
376374// it might be a problem with the actual bootleg
377static void draw_sprites_bootleg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen )
375void psikyo_state::draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectangle &cliprect, int trans_pen )
378376{
379   psikyo_state *state = machine.driver_data<psikyo_state>();
380377
381378   /* tile layers 0 & 1 have priorities 1 & 2 */
382379   static const int pri[] = { 0, 0xfc, 0xff, 0xff };
383380   int offs;
384   UINT16 *spritelist = (UINT16 *)(state->m_spritebuf2 + 0x1800 / 4);
385   UINT8 *TILES = machine.root_device().memregion("spritelut")->base();    // Sprites LUT
386   int TILES_LEN = machine.root_device().memregion("spritelut")->bytes();
381   UINT16 *spritelist = (UINT16 *)(m_spritebuf2 + 0x1800 / 4);
382   UINT8 *TILES = machine().root_device().memregion("spritelut")->base();    // Sprites LUT
383   int TILES_LEN = machine().root_device().memregion("spritelut")->bytes();
387384
388   int width = machine.primary_screen->width();
389   int height = machine.primary_screen->height();
385   int width = machine().primary_screen->width();
386   int height = machine().primary_screen->height();
390387
391388   /* Exit if sprites are disabled */
392389   if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1)
r20973r20974
415412      sprite = spritelist[BYTE_XOR_BE(offs)];
416413
417414      sprite %= 0x300;
418      source = &state->m_spritebuf2[sprite * 8 / 4];
415      source = &m_spritebuf2[sprite * 8 / 4];
419416
420417      /* Draw this sprite */
421418
r20973r20974
447444      zoomy = 32 - zoomy;
448445
449446
450      if (state->flip_screen())
447      if (flip_screen())
451448      {
452449         x = width  - x - (nx * zoomx) / 2;
453450         y = height - y - (ny * zoomy) / 2;
r20973r20974
468465            int addr = (code * 2) & (TILES_LEN-1);
469466
470467            if (zoomx == 32 && zoomy == 32)
471               pdrawgfx_transpen(bitmap,cliprect,machine.gfx[0],
468               pdrawgfx_transpen(bitmap,cliprect,machine().gfx[0],
472469                     TILES[addr+1] * 256 + TILES[addr],
473470                     attr >> 8,
474471                     flipx, flipy,
475472                     x + dx * 16, y + dy * 16,
476                     machine.priority_bitmap,
473                     machine().priority_bitmap,
477474                     pri[(attr & 0xc0) >> 6],trans_pen);
478475            else
479               pdrawgfxzoom_transpen(bitmap,cliprect,machine.gfx[0],
476               pdrawgfxzoom_transpen(bitmap,cliprect,machine().gfx[0],
480477                        TILES[addr+1] * 256 + TILES[addr],
481478                        attr >> 8,
482479                        flipx, flipy,
483480                        x + (dx * zoomx) / 2, y + (dy * zoomy) / 2,
484481                        zoomx << 11,zoomy << 11,
485                        machine.priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen);
482                        machine().priority_bitmap,pri[(attr & 0xc0) >> 6],trans_pen);
486483
487484            code++;
488485         }
r20973r20974
500497
501498***************************************************************************/
502499
503static int tilemap_width( int size )
500int psikyo_state::tilemap_width( int size )
504501{
505502   if (size == 0)
506503      return 0x80 * 16;
r20973r20974
561558   /* For gfx banking for s1945jn/gunbird/btlkroad */
562559   if (m_ka302c_banking)
563560   {
564      psikyo_switch_banks(machine(), 0, (layer0_ctrl & 0x400) >> 10);
565      psikyo_switch_banks(machine(), 1, (layer1_ctrl & 0x400) >> 10);
561      psikyo_switch_banks(0, (layer0_ctrl & 0x400) >> 10);
562      psikyo_switch_banks(1, (layer1_ctrl & 0x400) >> 10);
566563   }
567564
568565   switch ((layer0_ctrl & 0x00c0) >> 6)
r20973r20974
672669      tmptilemap1->draw(bitmap, cliprect, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2);
673670
674671   if (layers_ctrl & 4)
675      draw_sprites(machine(), bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15));
672      draw_sprites(bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15));
676673
677674   return 0;
678675}
r20973r20974
734731   /* For gfx banking for s1945jn/gunbird/btlkroad */
735732   if (m_ka302c_banking)
736733   {
737      psikyo_switch_banks(machine(), 0, (layer0_ctrl & 0x400) >> 10);
738      psikyo_switch_banks(machine(), 1, (layer1_ctrl & 0x400) >> 10);
734      psikyo_switch_banks(0, (layer0_ctrl & 0x400) >> 10);
735      psikyo_switch_banks(1, (layer1_ctrl & 0x400) >> 10);
739736   }
740737
741738   switch ((layer0_ctrl & 0x00c0) >> 6)
r20973r20974
845842      tmptilemap1->draw(bitmap, cliprect, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2);
846843
847844   if (layers_ctrl & 4)
848      draw_sprites_bootleg(machine(), bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15));
845      draw_sprites_bootleg(bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15));
849846
850847   return 0;
851848}
trunk/src/mame/video/pcktgal.c
r20973r20974
3131   }
3232}
3333
34static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
34void pcktgal_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
3535{
36   pcktgal_state *state = machine.driver_data<pcktgal_state>();
37   UINT8 *spriteram = state->m_spriteram;
36   UINT8 *spriteram = m_spriteram;
3837   int offs;
3938
40   for (offs = 0;offs < state->m_spriteram.bytes();offs += 4)
39   for (offs = 0;offs < m_spriteram.bytes();offs += 4)
4140   {
4241      if (spriteram[offs] != 0xf8)
4342      {
r20973r20974
4948
5049         flipx = spriteram[offs+1] & 0x04;
5150         flipy = spriteram[offs+1] & 0x02;
52         if (state->flip_screen()) {
51         if (flip_screen()) {
5352            sx=240-sx;
5453            sy=240-sy;
5554            if (flipx) flipx=0; else flipx=1;
5655            if (flipy) flipy=0; else flipy=1;
5756         }
5857
59         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
58         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
6059               spriteram[offs+3] + ((spriteram[offs+1] & 1) << 8),
6160               (spriteram[offs+1] & 0x70) >> 4,
6261               flipx,flipy,
r20973r20974
6968{
7069//  flip_screen_set(machine().device<deco_bac06_device>("tilegen1")->get_flip_state());
7170   machine().device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(machine(),bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
72   draw_sprites(machine(), bitmap, cliprect);
71   draw_sprites(bitmap, cliprect);
7372   return 0;
7473}
7574
r20973r20974
7776{
7877   // the bootleg doesn't properly set the tilemap registers, because it's on non-original hardware, which probably doesn't have the flexible tilemaps.
7978   machine().device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw_bootleg(machine(),bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0, 2);
80   draw_sprites(machine(), bitmap, cliprect);
81   return 0;}
79   draw_sprites(bitmap, cliprect);
80   return 0;
81}
trunk/src/mame/video/playmark.c
r20973r20974
385385
386386***************************************************************************/
387387
388static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift )
388void playmark_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift )
389389{
390   playmark_state *state = machine.driver_data<playmark_state>();
391   int offs, start_offset = state->m_spriteram.bytes() / 2 - 4;
392   int height = machine.gfx[0]->height();
393   int colordiv = machine.gfx[0]->granularity() / 16;
394   UINT16 *spriteram = state->m_spriteram;
390   int offs, start_offset = m_spriteram.bytes() / 2 - 4;
391   int height = machine().gfx[0]->height();
392   int colordiv = machine().gfx[0]->granularity() / 16;
393   UINT16 *spriteram = m_spriteram;
395394
396395   // find the "end of list" to draw the sprites in reverse order
397   for (offs = 4; offs < state->m_spriteram.bytes() / 2; offs += 4)
396   for (offs = 4; offs < m_spriteram.bytes() / 2; offs += 4)
398397   {
399398      if (spriteram[offs + 3 - 4] == 0x2000) /* end of list marker */
400399      {
r20973r20974
419418      if(!pri && (color & 0x0c) == 0x0c)
420419         pri = 2;
421420
422      pdrawgfx_transpen(bitmap,cliprect,machine.gfx[0],
421      pdrawgfx_transpen(bitmap,cliprect,machine().gfx[0],
423422               code,
424423               color,
425424               flipx,0,
426               sx + state->m_xoffset,sy + state->m_yoffset,
427               machine.priority_bitmap,state->m_pri_masks[pri],0);
425               sx + m_xoffset,sy + m_yoffset,
426               machine().priority_bitmap,m_pri_masks[pri],0);
428427   }
429428}
430429
431430
432static void bigtwinb_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift )
431void playmark_state::bigtwinb_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int codeshift )
433432{
434   playmark_state *state = machine.driver_data<playmark_state>();
435   int offs, start_offset = state->m_spriteram.bytes() / 2 - 4;
436   int height = machine.gfx[0]->height();
437   UINT16 *spriteram = state->m_spriteram;
433   int offs, start_offset = m_spriteram.bytes() / 2 - 4;
434   int height = machine().gfx[0]->height();
435   UINT16 *spriteram = m_spriteram;
438436
439437   // find the "end of list" to draw the sprites in reverse order
440   for (offs = 4; offs < state->m_spriteram.bytes() / 2; offs += 4)
438   for (offs = 4; offs < m_spriteram.bytes() / 2; offs += 4)
441439   {
442440      if (spriteram[offs + 3 - 4] == 0x2000) /* end of list marker */
443441      {
r20973r20974
458456      code = spriteram[offs + 2] >> codeshift;
459457      color = ((spriteram[offs + 1] & 0xf000) >> 12);
460458
461      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
459      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
462460               code,
463461               color,
464462               flipx,0,
465               sx + state->m_xoffset,sy + state->m_yoffset, 0);
463               sx + m_xoffset,sy + m_yoffset, 0);
466464   }
467465}
468466
469static void draw_bitmap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
467void playmark_state::draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect )
470468{
471   playmark_state *state = machine.driver_data<playmark_state>();
472469   int x, y, count;
473470   int color;
474471   UINT8 *pri;
r20973r20974
478475   {
479476      for (x = 0; x < 512; x++)
480477      {
481         color = state->m_bgvideoram[count] & 0xff;
478         color = m_bgvideoram[count] & 0xff;
482479
483480         if (color)
484481         {
485            if (state->m_bg_full_size)
482            if (m_bg_full_size)
486483            {
487               bitmap.pix16((y + state->m_bgscrolly) & 0x1ff, (x + state->m_bgscrollx) & 0x1ff) = 0x100 + color;
484               bitmap.pix16((y + m_bgscrolly) & 0x1ff, (x + m_bgscrollx) & 0x1ff) = 0x100 + color;
488485
489               pri = &machine.priority_bitmap.pix8((y + state->m_bgscrolly) & 0x1ff);
490               pri[(x + state->m_bgscrollx) & 0x1ff] |= 2;
486               pri = &machine().priority_bitmap.pix8((y + m_bgscrolly) & 0x1ff);
487               pri[(x + m_bgscrollx) & 0x1ff] |= 2;
491488            }
492489            else
493490            {
494491               /* 50% size */
495492               if(!(x % 2) && !(y % 2))
496493               {
497                  bitmap.pix16((y / 2 + state->m_bgscrolly) & 0x1ff, (x / 2 + state->m_bgscrollx) & 0x1ff) = 0x100 + color;
494                  bitmap.pix16((y / 2 + m_bgscrolly) & 0x1ff, (x / 2 + m_bgscrollx) & 0x1ff) = 0x100 + color;
498495
499                  pri = &machine.priority_bitmap.pix8((y / 2 + state->m_bgscrolly) & 0x1ff);
500                  pri[(x / 2 + state->m_bgscrollx) & 0x1ff] |= 2;
496                  pri = &machine().priority_bitmap.pix8((y / 2 + m_bgscrolly) & 0x1ff);
497                  pri[(x / 2 + m_bgscrollx) & 0x1ff] |= 2;
501498               }
502499            }
503500         }
r20973r20974
513510
514511   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
515512   if (m_bg_enable)
516      draw_bitmap(machine(), bitmap, cliprect);
517   draw_sprites(machine(), bitmap, cliprect, 4);
513      draw_bitmap(bitmap, cliprect);
514   draw_sprites(bitmap, cliprect, 4);
518515   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
519516   return 0;
520517}
r20973r20974
527524   {
528525      m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
529526      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
530      bigtwinb_draw_sprites(machine(), bitmap, cliprect, 4);
527      bigtwinb_draw_sprites(bitmap, cliprect, 4);
531528      m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
532529   }
533530   else
r20973r20974
541538
542539   m_fg_tilemap->draw(bitmap, cliprect, 0, 1);
543540   if (m_bg_enable)
544      draw_bitmap(machine(), bitmap, cliprect);
541      draw_bitmap(bitmap, cliprect);
545542   m_tx_tilemap->draw(bitmap, cliprect, 0, 4);
546   draw_sprites(machine(), bitmap, cliprect, 2);
543   draw_sprites(bitmap, cliprect, 2);
547544   return 0;
548545}
549546
r20973r20974
567564
568565   m_bg_tilemap->draw(bitmap, cliprect, 0, 1);
569566   m_fg_tilemap->draw(bitmap, cliprect, 0, 2);
570   draw_sprites(machine(), bitmap, cliprect, 0);
567   draw_sprites(bitmap, cliprect, 0);
571568   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
572569   return 0;
573570}
r20973r20974
581578   {
582579      m_bg_tilemap->draw(bitmap, cliprect, 0, 1);
583580      m_fg_tilemap->draw(bitmap, cliprect, 0, 2);
584      draw_sprites(machine(), bitmap, cliprect, 2);
581      draw_sprites(bitmap, cliprect, 2);
585582      m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
586583   }
587584   else
trunk/src/mame/video/portrait.c
r20973r20974
2121   m_fgvideoram[offset] = data;
2222}
2323
24INLINE void get_tile_info( running_machine &machine, tile_data &tileinfo, int tile_index, const UINT8 *source )
24inline void portrait_state::get_tile_info( tile_data &tileinfo, int tile_index, const UINT8 *source )
2525{
2626   int attr    = source[tile_index*2+0];
2727   int tilenum = source[tile_index*2+1];
r20973r20974
4949   else
5050      color = ((tilenum&0xff)>>1)+0x80;
5151
52   SET_TILE_INFO( 0, tilenum, color, flags );
52   SET_TILE_INFO_MEMBER( 0, tilenum, color, flags );
5353}
5454
5555TILE_GET_INFO_MEMBER(portrait_state::get_bg_tile_info)
5656{
57   get_tile_info( machine(), tileinfo, tile_index, m_bgvideoram );
57   get_tile_info(tileinfo, tile_index, m_bgvideoram );
5858}
5959
6060TILE_GET_INFO_MEMBER(portrait_state::get_fg_tile_info)
6161{
62   get_tile_info( machine(), tileinfo, tile_index, m_fgvideoram );
62   get_tile_info(tileinfo, tile_index, m_fgvideoram );
6363}
6464
6565void portrait_state::video_start()
r20973r20974
125125}
126126
127127
128static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
128void portrait_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
129129{
130   portrait_state *state = machine.driver_data<portrait_state>();
131   UINT8 *source = state->m_spriteram;
130   UINT8 *source = m_spriteram;
132131   UINT8 *finish = source + 0x200;
133132
134133   while( source < finish )
r20973r20974
151150
152151      if(attr & 0x08) sy |= 0x100;
153152
154      sx += (source - state->m_spriteram) - 8;
153      sx += (source - m_spriteram) - 8;
155154      sx &= 0x1ff;
156155
157156      sy = (512 - 64) - sy;
r20973r20974
163162         break;
164163
165164      case 0x40:
166         sy -= state->m_scroll;
165         sy -= m_scroll;
167166         break;
168167
169168      case 0x80:
170         sy -= state->m_scroll;
169         sy -= m_scroll;
171170         break;
172171
173172      case 0xc0:
r20973r20974
175174
176175      }
177176
178      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
177      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
179178            tilenum,color,
180179            0,fy,
181180            sx,sy,7);
r20973r20974
203202   m_background->draw(bitmap, cliprect_scroll, 0, 0);
204203   m_foreground->draw(bitmap, cliprect_scroll, 0, 0);
205204
206   draw_sprites(machine(), bitmap,cliprect);
205   draw_sprites(bitmap,cliprect);
207206   return 0;
208207}
trunk/src/mame/video/pirates.c
r20973r20974
6767
6868
6969
70static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
70void pirates_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
7171{
72   pirates_state *state = machine.driver_data<pirates_state>();
73   gfx_element *gfx = machine.gfx[1];
74   UINT16 *source = state->m_spriteram + 4;
72   gfx_element *gfx = machine().gfx[1];
73   UINT16 *source = m_spriteram + 4;
7574   UINT16 *finish = source + 0x800/2-4;
7675
7776   while( source<finish )
r20973r20974
106105   m_fg_tilemap->set_scrollx(0,m_scroll[0]);
107106   m_bg_tilemap->draw(bitmap, cliprect, 0,0);
108107   m_fg_tilemap->draw(bitmap, cliprect, 0,0);
109   draw_sprites(machine(),bitmap,cliprect);
108   draw_sprites(bitmap,cliprect);
110109   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
111110   return 0;
112111}
trunk/src/mame/video/popper.c
r20973r20974
187187   m_tilemap_clip = machine().primary_screen->visible_area();
188188}
189189
190static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect )
190void popper_state::draw_sprites( bitmap_ind16 &bitmap,const rectangle &cliprect )
191191{
192   popper_state *state = machine.driver_data<popper_state>();
193192   int offs, sx, sy, flipx, flipy;
194193
195   for (offs = 0; offs < state->m_spriteram.bytes() - 4; offs += 4)
194   for (offs = 0; offs < m_spriteram.bytes() - 4; offs += 4)
196195   {
197196      //if y position is in the current strip
198      if (state->m_spriteram[offs + 1] && (((state->m_spriteram[offs] + (state->m_flipscreen ? 2 : 0)) & 0xf0) == (0x0f - offs / 0x80) << 4))
197      if (m_spriteram[offs + 1] && (((m_spriteram[offs] + (m_flipscreen ? 2 : 0)) & 0xf0) == (0x0f - offs / 0x80) << 4))
199198      {
200199         //offs     y pos
201200         //offs+1   sprite number
r20973r20974
207206         //----xxxx colour
208207         //offs+3   x pos
209208
210         sx = state->m_spriteram[offs + 3];
211         sy = 240 - state->m_spriteram[offs];
212         flipx = (state->m_spriteram[offs + 2] & 0x40) >> 6;
213         flipy = (state->m_spriteram[offs + 2] & 0x80) >> 7;
209         sx = m_spriteram[offs + 3];
210         sy = 240 - m_spriteram[offs];
211         flipx = (m_spriteram[offs + 2] & 0x40) >> 6;
212         flipy = (m_spriteram[offs + 2] & 0x80) >> 7;
214213
215         if (state->m_flipscreen)
214         if (m_flipscreen)
216215         {
217216            sx = 248 - sx;
218217            sy = 242 - sy;
r20973r20974
220219            flipy = !flipy;
221220         }
222221
223         drawgfx_transpen(bitmap, cliprect, machine.gfx[1],
224               state->m_spriteram[offs + 1],
225               (state->m_spriteram[offs + 2] & 0x0f),
222         drawgfx_transpen(bitmap, cliprect, machine().gfx[1],
223               m_spriteram[offs + 1],
224               (m_spriteram[offs + 2] & 0x0f),
226225               flipx,flipy,
227226               sx,sy,0);
228227      }
r20973r20974
245244   m_ol_p123_tilemap->draw(bitmap, finalclip, TILEMAP_DRAW_LAYER1, 0);
246245   m_ol_p0_tilemap->draw(bitmap, finalclip, TILEMAP_DRAW_LAYER1, 0);
247246
248   draw_sprites(machine(), bitmap, cliprect);
247   draw_sprites(bitmap, cliprect);
249248
250249   m_p123_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
251250   m_p0_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
trunk/src/mame/video/psychic5.c
r20973r20974
2323  Palette color
2424***************************************************************************/
2525
26static void psychic5_change_palette(running_machine &machine, int color, int offset)
26void psychic5_state::psychic5_change_palette(int color, int offset)
2727{
28   psychic5_state *state = machine.driver_data<psychic5_state>();
29   UINT8 lo = state->m_ps5_palette_ram[offset & ~1];
30   UINT8 hi = state->m_ps5_palette_ram[offset | 1];
28   UINT8 lo = m_ps5_palette_ram[offset & ~1];
29   UINT8 hi = m_ps5_palette_ram[offset | 1];
3130   jal_blend_set(color, hi & 0x0f);
32   palette_set_color_rgb(machine, color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
31   palette_set_color_rgb(machine(), color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
3332}
3433
35static void psychic5_change_bg_palette(running_machine &machine, int color, int lo_offs, int hi_offs)
34void psychic5_state::psychic5_change_bg_palette(int color, int lo_offs, int hi_offs)
3635{
37   psychic5_state *state = machine.driver_data<psychic5_state>();
3836   UINT8 r,g,b,lo,hi,ir,ig,ib,ix;
3937   rgb_t irgb;
4038
4139   /* red,green,blue intensities */
42   ir = pal4bit(state->m_palette_intensity >> 12);
43   ig = pal4bit(state->m_palette_intensity >>  8);
44   ib = pal4bit(state->m_palette_intensity >>  4);
45   ix = state->m_palette_intensity & 0x0f;
40   ir = pal4bit(m_palette_intensity >> 12);
41   ig = pal4bit(m_palette_intensity >>  8);
42   ib = pal4bit(m_palette_intensity >>  4);
43   ix = m_palette_intensity & 0x0f;
4644
4745   irgb = MAKE_RGB(ir,ig,ib);
4846
49   lo = state->m_ps5_palette_ram[lo_offs];
50   hi = state->m_ps5_palette_ram[hi_offs];
47   lo = m_ps5_palette_ram[lo_offs];
48   hi = m_ps5_palette_ram[hi_offs];
5149
5250   /* red,green,blue component */
5351   r = pal4bit(lo >> 4);
r20973r20974
5553   b = pal4bit(hi >> 4);
5654
5755   /* Grey background enable */
58   if (state->m_bg_status & 2)
56   if (m_bg_status & 2)
5957   {
6058      UINT8 val = (r + g + b) / 3;        /* Grey */
6159      /* Just leave plain grey */
62      palette_set_color(machine,color,jal_blend_func(MAKE_RGB(val,val,val),irgb,ix));
60      palette_set_color(machine(),color,jal_blend_func(MAKE_RGB(val,val,val),irgb,ix));
6361   }
6462   else
6563   {
6664      /* Seems fishy, but the title screen would be black otherwise... */
67      if (!(state->m_title_screen & 1))
65      if (!(m_title_screen & 1))
6866      {
6967         /* Leave the world as-is */
70         palette_set_color(machine,color,jal_blend_func(MAKE_RGB(r,g,b),irgb,ix));
68         palette_set_color(machine(),color,jal_blend_func(MAKE_RGB(r,g,b),irgb,ix));
7169      }
7270   }
7371}
7472
75static void set_background_palette_intensity(running_machine &machine)
73void psychic5_state::set_background_palette_intensity()
7674{
77   psychic5_state *state = machine.driver_data<psychic5_state>();
7875   int i;
79   state->m_palette_intensity = state->m_ps5_palette_ram[BG_PAL_INTENSITY_BU] |
80                  (state->m_ps5_palette_ram[BG_PAL_INTENSITY_RG]<<8);
76   m_palette_intensity = m_ps5_palette_ram[BG_PAL_INTENSITY_BU] |
77                  (m_ps5_palette_ram[BG_PAL_INTENSITY_RG]<<8);
8178
8279   /* for all of the background palette */
8380   for (i = 0; i < 0x100; i++)
84      psychic5_change_bg_palette(machine,state->m_bg_palette_base+i,state->m_bg_palette_ram_base+i*2,state->m_bg_palette_ram_base+i*2+1);
81      psychic5_change_bg_palette(m_bg_palette_base+i,m_bg_palette_ram_base+i*2,m_bg_palette_ram_base+i*2+1);
8582}
8683
8784
r20973r20974
147144         m_bg_status = m_ps5_io_ram[BG_SCREEN_MODE];
148145      }
149146      else if (offset >= 0x400 && offset <= 0x5ff)    /* Sprite color */
150         psychic5_change_palette(machine(),((offset >> 1) & 0xff)+0x000,offset-0x400);
147         psychic5_change_palette(((offset >> 1) & 0xff)+0x000,offset-0x400);
151148      else if (offset >= 0x800 && offset <= 0x9ff)    /* BG color */
152         psychic5_change_palette(machine(),((offset >> 1) & 0xff)+0x100,offset-0x400);
149         psychic5_change_palette(((offset >> 1) & 0xff)+0x100,offset-0x400);
153150      else if (offset >= 0xa00 && offset <= 0xbff)    /* Text color */
154         psychic5_change_palette(machine(),((offset >> 1) & 0xff)+0x200,offset-0x400);
151         psychic5_change_palette(((offset >> 1) & 0xff)+0x200,offset-0x400);
155152      else if (offset >= 0x1000)
156153         m_fg_tilemap->mark_tile_dirty((offset-0x1000) >> 1);
157154   }
r20973r20974
184181      else if (offset >= 0x0800 && offset <= 0x0fff)
185182         m_fg_tilemap->mark_tile_dirty((offset & 0x7ff) >> 1);
186183      else if (offset >= 0x1000 && offset <= 0x15ff)
187         psychic5_change_palette(machine(), (offset >> 1) & 0x3ff, offset-0x1000);
184         psychic5_change_palette((offset >> 1) & 0x3ff, offset-0x1000);
188185   }
189186}
190187
r20973r20974
296293  Screen refresh
297294***************************************************************************/
298295
299#define DRAW_SPRITE(code, sx, sy) jal_blend_drawgfx(bitmap, cliprect, machine.gfx[0], code, color, flipx, flipy, sx, sy, 15);
296#define DRAW_SPRITE(code, sx, sy) jal_blend_drawgfx(bitmap, cliprect, machine().gfx[0], code, color, flipx, flipy, sx, sy, 15);
300297
301static void draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
298void psychic5_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
302299{
303   psychic5_state *state = machine.driver_data<psychic5_state>();
304   UINT8 *spriteram = state->m_spriteram;
300   UINT8 *spriteram = m_spriteram;
305301   int offs;
306302
307303   /* Draw the sprites */
308   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 16)
304   for (offs = 0; offs < m_spriteram.bytes(); offs += 16)
309305   {
310306      int attr  = spriteram[offs + 13];
311307      int code  = spriteram[offs + 14] | ((attr & 0xc0) << 2);
r20973r20974
319315      if (attr & 0x01) sx -= 256;
320316      if (attr & 0x04) sy -= 256;
321317
322      if (state->flip_screen())
318      if (flip_screen())
323319      {
324320         sx = 224 - sx;
325321         sy = 224 - sy;
r20973r20974
344340      }
345341      else
346342      {
347         if (state->flip_screen())
343         if (flip_screen())
348344            DRAW_SPRITE(code, sx + 16, sy + 16)
349345         else
350346            DRAW_SPRITE(code, sx, sy)
r20973r20974
352348   }
353349}
354350
355static void draw_background(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect)
351void psychic5_state::draw_background(bitmap_rgb32 &bitmap, const rectangle &cliprect)
356352{
357   psychic5_state *state = machine.driver_data<psychic5_state>();
358   UINT8 *spriteram = state->m_spriteram;
353   UINT8 *spriteram = m_spriteram;
359354
360355   rectangle clip = cliprect;
361356
362   set_background_palette_intensity(machine);
357   set_background_palette_intensity();
363358
364   if (!(state->m_title_screen & 1))
359   if (!(m_title_screen & 1))
365360   {
366      state->m_bg_clip_mode = 0;
367      state->m_sx1 = state->m_sy1 = state->m_sy2 = 0;
361      m_bg_clip_mode = 0;
362      m_sx1 = m_sy1 = m_sy2 = 0;
368363   }
369364   else
370365   {
371      int sy1_old = state->m_sy1;
372      int sx1_old = state->m_sx1;
373      int sy2_old = state->m_sy2;
366      int sy1_old = m_sy1;
367      int sx1_old = m_sx1;
368      int sy2_old = m_sy2;
374369
375      state->m_sy1 = spriteram[11];       /* sprite 0 */
376      state->m_sx1 = spriteram[12];
377      state->m_sy2 = spriteram[11+128];   /* sprite 8 */
370      m_sy1 = spriteram[11];       /* sprite 0 */
371      m_sx1 = spriteram[12];
372      m_sy2 = spriteram[11+128];   /* sprite 8 */
378373
379      switch (state->m_bg_clip_mode)
374      switch (m_bg_clip_mode)
380375      {
381      case  0: case  4: if (sy1_old != state->m_sy1) state->m_bg_clip_mode++; break;
382      case  2: case  6: if (sy2_old != state->m_sy2) state->m_bg_clip_mode++; break;
376      case  0: case  4: if (sy1_old != m_sy1) m_bg_clip_mode++; break;
377      case  2: case  6: if (sy2_old != m_sy2) m_bg_clip_mode++; break;
383378      case  8: case 10:
384      case 12: case 14: if (sx1_old != state->m_sx1) state->m_bg_clip_mode++; break;
385      case  1: case  5: if (state->m_sy1 == 0xf0) state->m_bg_clip_mode++; break;
386      case  3: case  7: if (state->m_sy2 == 0xf0) state->m_bg_clip_mode++; break;
387      case  9: case 11: if (state->m_sx1 == 0xf0) state->m_bg_clip_mode++; break;
388      case 13: case 15: if (sx1_old == 0xf0) state->m_bg_clip_mode++;
389      case 16: if (state->m_sy1 != 0x00) state->m_bg_clip_mode = 0; break;
379      case 12: case 14: if (sx1_old != m_sx1) m_bg_clip_mode++; break;
380      case  1: case  5: if (m_sy1 == 0xf0) m_bg_clip_mode++; break;
381      case  3: case  7: if (m_sy2 == 0xf0) m_bg_clip_mode++; break;
382      case  9: case 11: if (m_sx1 == 0xf0) m_bg_clip_mode++; break;
383      case 13: case 15: if (sx1_old == 0xf0) m_bg_clip_mode++;
384      case 16: if (m_sy1 != 0x00) m_bg_clip_mode = 0; break;
390385      }
391386
392      switch (state->m_bg_clip_mode)
387      switch (m_bg_clip_mode)
393388      {
394389      case  0: case  4: case  8: case 12: case 16:
395390         clip.set(0, 0, 0, 0);
396391         break;
397      case  1: clip.min_y = state->m_sy1; break;
398      case  3: clip.max_y = state->m_sy2; break;
399      case  5: clip.max_y = state->m_sy1; break;
400      case  7: clip.min_y = state->m_sy2; break;
401      case  9: case 15: clip.min_x = state->m_sx1; break;
402      case 11: case 13: clip.max_x = state->m_sx1; break;
392      case  1: clip.min_y = m_sy1; break;
393      case  3: clip.max_y = m_sy2; break;
394      case  5: clip.max_y = m_sy1; break;
395      case  7: clip.min_y = m_sy2; break;
396      case  9: case 15: clip.min_x = m_sx1; break;
397      case 11: case 13: clip.max_x = m_sx1; break;
403398      }
404399
405      if (state->flip_screen())
400      if (flip_screen())
406401         clip.set(255 - clip.max_x, 255 - clip.min_x, 255 - clip.max_y, 255 - clip.min_y);
407402   }
408403
409   state->m_bg_tilemap->draw(bitmap, clip, 0, 0);
404   m_bg_tilemap->draw(bitmap, clip, 0, 0);
410405}
411406
412407UINT32 psychic5_state::screen_update_psychic5(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
413408{
414409   bitmap.fill(get_black_pen(machine()), cliprect);
415410   if (m_bg_status & 1)    /* Backgound enable */
416      draw_background(machine(), bitmap, cliprect);
411      draw_background(bitmap, cliprect);
417412   if (!(m_title_screen & 1))
418      draw_sprites(machine(), bitmap, cliprect);
413      draw_sprites(bitmap, cliprect);
419414   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
420415   return 0;
421416}
r20973r20974
426421      m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
427422   else
428423      bitmap.fill(machine().pens[0x0ff], cliprect);
429   draw_sprites(machine(), bitmap, cliprect);
424   draw_sprites(bitmap, cliprect);
430425   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
431426   return 0;
432427}
trunk/src/mame/video/pingpong.c
r20973r20974
110110   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pingpong_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
111111}
112112
113static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
113void pingpong_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
114114{
115115   /* This is strange; it's unlikely that the sprites actually have a hardware */
116116   /* clipping region, but I haven't found another way to have them masked by */
117117   /* the characters at the top and bottom of the screen. */
118118   const rectangle spritevisiblearea(0*8, 32*8-1, 4*8, 29*8-1);
119119
120   pingpong_state *state = machine.driver_data<pingpong_state>();
121   UINT8 *spriteram = state->m_spriteram;
120   UINT8 *spriteram = m_spriteram;
122121   int offs;
123122
124   for (offs = state->m_spriteram.bytes() - 4;offs >= 0;offs -= 4)
123   for (offs = m_spriteram.bytes() - 4;offs >= 0;offs -= 4)
125124   {
126125      int sx,sy,flipx,flipy,color,schar;
127126
r20973r20974
134133      color = spriteram[offs] & 0x1f;
135134      schar = spriteram[offs + 2] & 0x7f;
136135
137      drawgfx_transmask(bitmap,spritevisiblearea,machine.gfx[1],
136      drawgfx_transmask(bitmap,spritevisiblearea,machine().gfx[1],
138137            schar,
139138            color,
140139            flipx,flipy,
141140            sx,sy,
142            colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 0));
141            colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 0));
143142   }
144143}
145144
146145UINT32 pingpong_state::screen_update_pingpong(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
147146{
148147   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
149   draw_sprites(machine(), bitmap, cliprect);
148   draw_sprites(bitmap, cliprect);
150149   return 0;
151150}
trunk/src/mame/video/pokechmp.c
r20973r20974
3535         8, 8, 32, 32);
3636}
3737
38static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
38void pokechmp_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
3939{
40   pokechmp_state *state = machine.driver_data<pokechmp_state>();
41   UINT8 *spriteram = state->m_spriteram;
40   UINT8 *spriteram = m_spriteram;
4241   int offs;
4342
44   for (offs = 0;offs < state->m_spriteram.bytes();offs += 4)
43   for (offs = 0;offs < m_spriteram.bytes();offs += 4)
4544   {
4645      if (spriteram[offs] != 0xf8)
4746      {
r20973r20974
5352
5453         flipx = spriteram[offs+1] & 0x04;
5554         flipy = spriteram[offs+1] & 0x02;
56         if (state->flip_screen()) {
55         if (flip_screen()) {
5756            sx=240-sx;
5857            sy=240-sy;
5958            if (flipx) flipx=0; else flipx=1;
r20973r20974
6362         if (spriteram[offs+1] & 0x01) tileno += 0x100;
6463         if (spriteram[offs+1] & 0x08) tileno += 0x200;
6564
66         drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
65         drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
6766               tileno,
6867               (spriteram[offs+1] & 0xf0) >> 4,
6968               flipx,flipy,
r20973r20974
7574UINT32 pokechmp_state::screen_update_pokechmp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
7675{
7776   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
78   draw_sprites(machine(), bitmap, cliprect);
77   draw_sprites(bitmap, cliprect);
7978   return 0;
8079}
trunk/src/mame/video/polepos.c
r20973r20974
340340
341341***************************************************************************/
342342
343static void draw_road(running_machine &machine, bitmap_ind16 &bitmap)
343void polepos_state::draw_road(bitmap_ind16 &bitmap)
344344{
345   polepos_state *state = machine.driver_data<polepos_state>();
346   const UINT8 *road_control = state->memregion("gfx5")->base();
345   const UINT8 *road_control = memregion("gfx5")->base();
347346   const UINT8 *road_bits1 = road_control + 0x2000;
348347   const UINT8 *road_bits2 = road_control + 0x4000;
349348   int x, y, i;
r20973r20974
357356      pen_t pen_base;
358357
359358      /* first add the vertical position modifier and the vertical scroll */
360      yoffs = ((state->m_vertical_position_modifier[y] + state->m_road16_vscroll) >> 3) & 0x1ff;
359      yoffs = ((m_vertical_position_modifier[y] + m_road16_vscroll) >> 3) & 0x1ff;
361360
362361      /* then use that as a lookup into the road memory */
363      roadpal = state->m_road16_memory[yoffs] & 15;
362      roadpal = m_road16_memory[yoffs] & 15;
364363
365364      /* this becomes the palette base for the scanline */
366365      pen_base = 0x0b00 + (roadpal << 6);
367366
368367      /* now fetch the horizontal scroll offset for this scanline */
369      xoffs = state->m_road16_memory[0x380 + (y & 0x7f)] & 0x3ff;
368      xoffs = m_road16_memory[0x380 + (y & 0x7f)] & 0x3ff;
370369
371370      /* the road is drawn in 8-pixel chunks, so round downward and adjust the base */
372371      /* note that we assume there is at least 8 pixels of slop on the left/right */
r20973r20974
416415   }
417416}
418417
419static void zoom_sprite(running_machine &machine, bitmap_ind16 &bitmap,int big,
418void polepos_state::zoom_sprite(bitmap_ind16 &bitmap,int big,
420419      UINT32 code,UINT32 color,int flipx,int sx,int sy,
421420      int sizex,int sizey)
422421{
423   gfx_element *gfx = machine.gfx[big ? 3 : 2];
422   gfx_element *gfx = machine().gfx[big ? 3 : 2];
424423   const UINT8 *gfxdata = gfx->get_data(code % gfx->elements());
425   UINT8 *scaling_rom = machine.root_device().memregion("gfx6")->base();
426   UINT32 transmask = colortable_get_transpen_mask(machine.colortable, gfx, color, 0x1f);
424   UINT8 *scaling_rom = machine().root_device().memregion("gfx6")->base();
425   UINT32 transmask = colortable_get_transpen_mask(machine().colortable, gfx, color, 0x1f);
427426   int coloroffs = gfx->colorbase() + color * gfx->granularity();
428427   int x,y;
429428
r20973r20974
467466   }
468467}
469468
470static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
469void polepos_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
471470{
472   polepos_state *state = machine.driver_data<polepos_state>();
473   UINT16 *posmem = &state->m_sprite16_memory[0x380];
474   UINT16 *sizmem = &state->m_sprite16_memory[0x780];
471   UINT16 *posmem = &m_sprite16_memory[0x380];
472   UINT16 *sizmem = &m_sprite16_memory[0x780];
475473   int i;
476474
477475   for (i = 0; i < 64; i++, posmem += 2, sizmem += 2)
r20973r20974
487485      /* 128V input to the palette PROM */
488486      if (sy >= 128) color |= 0x40;
489487
490      zoom_sprite(machine, bitmap, (sizmem[0] & 0x8000) ? 1 : 0,
488      zoom_sprite(bitmap, (sizmem[0] & 0x8000) ? 1 : 0,
491489               code,
492490               color,
493491               flipx,
r20973r20974
502500   rectangle clip = cliprect;
503501   clip.max_y = 127;
504502   m_bg_tilemap->draw(bitmap, clip, 0,0);
505   draw_road(machine(), bitmap);
506   draw_sprites(machine(), bitmap,cliprect);
503   draw_road(bitmap);
504   draw_sprites(bitmap,cliprect);
507505   m_tx_tilemap->draw(bitmap, cliprect, 0,0);
508506   return 0;
509507}
trunk/src/mame/video/pbaction.c
r20973r20974
7676   m_fg_tilemap->set_transparent_pen(0);
7777}
7878
79static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
79void pbaction_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
8080{
81   pbaction_state *state = machine.driver_data<pbaction_state>();
82   UINT8 *spriteram = state->m_spriteram;
81   UINT8 *spriteram = m_spriteram;
8382   int offs;
8483
85   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
84   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
8685   {
8786      int sx, sy, flipx, flipy;
8887
r20973r20974
10099      flipx = spriteram[offs + 1] & 0x40;
101100      flipy = spriteram[offs + 1] & 0x80;
102101
103      if (state->flip_screen())
102      if (flip_screen())
104103      {
105104         if (spriteram[offs] & 0x80)
106105         {
r20973r20974
116115         flipy = !flipy;
117116      }
118117
119      drawgfx_transpen(bitmap,cliprect,machine.gfx[(spriteram[offs] & 0x80) ? 3 : 2], /* normal or double size */
118      drawgfx_transpen(bitmap,cliprect,machine().gfx[(spriteram[offs] & 0x80) ? 3 : 2], /* normal or double size */
120119            spriteram[offs],
121120            spriteram[offs + 1] & 0x0f,
122121            flipx,flipy,
123            sx + (state->flip_screen() ? state->m_scroll : -state->m_scroll), sy,0);
122            sx + (flip_screen() ? m_scroll : -m_scroll), sy,0);
124123   }
125124}
126125
127126UINT32 pbaction_state::screen_update_pbaction(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
128127{
129128   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
130   draw_sprites(machine(), bitmap, cliprect);
129   draw_sprites(bitmap, cliprect);
131130   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
132131   return 0;
133132}
trunk/src/mame/video/psikyosh.c
r20973r20974
140140    draw_scanline32_alpha - take an RGB-encoded UINT32
141141    scanline and alpha-blend it into the destination bitmap
142142-------------------------------------------------*/
143static void draw_scanline32_alpha(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, int alpha)
143void psikyosh_state::draw_scanline32_alpha(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, int alpha)
144144{
145145   DECLARE_NO_PRIORITY;
146146   UINT32 transpen = BG_TRANSPEN;
r20973r20974
152152    draw_scanline32_argb - take an ARGB-encoded UINT32
153153    scanline and alpha-blend it into the destination bitmap
154154-------------------------------------------------*/
155static void draw_scanline32_argb(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr)
155void psikyosh_state::draw_scanline32_argb(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr)
156156{
157157   DECLARE_NO_PRIORITY;
158158   UINT32 transpen = BG_TRANSPEN;
r20973r20974
164164    draw_scanline32_tranpens - take an RGB-encoded UINT32
165165    scanline and copy it into the destination bitmap, testing for the special ARGB transpen
166166-------------------------------------------------*/
167static void draw_scanline32_transpen(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr)
167void psikyosh_state::draw_scanline32_transpen(bitmap_rgb32 &bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr)
168168{
169169   DECLARE_NO_PRIORITY;
170170   UINT32 transpen = BG_TRANSPEN;
r20973r20974
261261
262262/* 'Normal' layers, no line/columnscroll. No per-line effects.
263263Zooming isn't supported just because it's not used and it would be slow */
264static void draw_bglayer( running_machine &machine, int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
264void psikyosh_state::draw_bglayer( int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
265265{
266   psikyosh_state *state = machine.driver_data<psikyosh_state>();
267266   gfx_element *gfx;
268267   int offs = 0, sx, sy;
269268   int scrollx, scrolly, regbank, tilebank, alpha, alphamap, zoom, pri, size, width;
270269
271270   assert(!BG_LINE(layer));
272271
273   gfx = BG_DEPTH_8BPP(layer) ? machine.gfx[1] : machine.gfx[0];
272   gfx = BG_DEPTH_8BPP(layer) ? machine().gfx[1] : machine().gfx[0];
274273   size = BG_LARGE(layer) ? 32 : 16;
275274   width = 16 * size;
276275
277276   regbank = BG_TYPE(layer);
278277
279   scrollx  = (state->m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000001ff) >> 0;
280   scrolly  = (state->m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x03ff0000) >> 16;
278   scrollx  = (m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000001ff) >> 0;
279   scrolly  = (m_bgram[(regbank * 0x800) / 4 + 0x3f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x03ff0000) >> 16;
281280
282   tilebank = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000000ff) >> 0;
283   alpha    = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00003f00) >> 8;
284   alphamap = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00008000) >> 15;
285   zoom     = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00ff0000) >> 16;
286   pri      = (state->m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0xff000000) >> 24;
281   tilebank = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x000000ff) >> 0;
282   alpha    = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00003f00) >> 8;
283   alphamap = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00008000) >> 15;
284   zoom     = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0x00ff0000) >> 16;
285   pri      = (m_bgram[(regbank * 0x800) / 4 + 0x7f0 / 4 + (layer * 0x04) / 4 - 0x4000 / 4] & 0xff000000) >> 24;
287286
288287   if(pri != req_pri) return;
289288
r20973r20974
304303         {
305304            int tileno, colour;
306305
307            tileno = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
308            colour = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
306            tileno = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
307            colour = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
309308
310309            drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */
311310
r20973r20974
324323
325324
326325/* populate bg_bitmap for the given bank if it's not already */
327static void cache_bitmap(int scanline, psikyosh_state *state, gfx_element *gfx, int size, int tilebank, int alpha, int *last_bank)
326void psikyosh_state::cache_bitmap(int scanline, gfx_element *gfx, int size, int tilebank, int alpha, int *last_bank)
328327{
329328   // test if the tile row is the cached one or not
330329   int sy = scanline / 16;
r20973r20974
335334   {
336335      rectangle cliprect;
337336
338      cliprect.set(0, state->m_bg_bitmap.width() - 1, sy * 16, cliprect.min_y + 16 - 1);
337      cliprect.set(0, m_bg_bitmap.width() - 1, sy * 16, cliprect.min_y + 16 - 1);
339338
340      state->m_bg_bitmap.fill(BG_TRANSPEN, cliprect);
339      m_bg_bitmap.fill(BG_TRANSPEN, cliprect);
341340      int width = size * 16;
342341
343342      int offs = size * sy;
r20973r20974
347346      {
348347         int tileno, colour;
349348
350         tileno = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
351         colour = (state->m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
349         tileno = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
350         colour = (m_bgram[(tilebank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
352351         int need_alpha = alpha < 0 ? -1 : 0xff; // store per-pen alpha in bitmap, otherwise don't since we'll need it per-line
353352
354353         if(tileno) { // valid tile, but blank in all games?
355            drawgfx_alphastore(state->m_bg_bitmap, state->m_bg_bitmap.cliprect(), gfx, tileno, colour, 0, 0, (16 * sx) & 0x1ff, ((16 * sy) & (width - 1)), need_alpha);
354            drawgfx_alphastore(m_bg_bitmap, m_bg_bitmap.cliprect(), gfx, tileno, colour, 0, 0, (16 * sx) & 0x1ff, ((16 * sy) & (width - 1)), need_alpha);
356355         }
357356
358357         offs++;
r20973r20974
366365Bitmap is first rendered to an ARGB image, taking into account the per-pen alpha (if used).
367366From there we extract data as we compose the image, one scanline at a time, blending the ARGB pixels
368367into the RGB32 bitmap (with either the alpha information from the ARGB, or per-line alpha */
369static void draw_bglayerscroll( running_machine &machine, int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
368void psikyosh_state::draw_bglayerscroll( int layer, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
370369{
371   psikyosh_state *state = machine.driver_data<psikyosh_state>();
372370   assert(BG_LINE(layer));
373371
374   gfx_element *gfx = BG_DEPTH_8BPP(layer) ? machine.gfx[1] : machine.gfx[0];
372   gfx_element *gfx = BG_DEPTH_8BPP(layer) ? machine().gfx[1] : machine().gfx[0];
375373   int size = BG_LARGE(layer) ? 32 : 16;
376374   int width = size * 16;
377375
378376   int linebank = BG_TYPE(layer);
379377
380378   /* cache rendered bitmap */
381   int last_bank[32]; // corresponds to bank of bitmap in state->m_bg_bitmap. bg_bitmap is split into 16/32-rows of one-tile high each
379   int last_bank[32]; // corresponds to bank of bitmap in m_bg_bitmap. bg_bitmap is split into 16/32-rows of one-tile high each
382380   for(int ii = 0; ii < 32; ii++) last_bank[ii] = -1;
383381
384382   int scr_width = cliprect.width();
385383   int scr_height = cliprect.height();
386   UINT32 *scroll_reg = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4];
387   UINT32 *pzab_reg   = &state->m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; // pri, zoom, alpha, bank
384   UINT32 *scroll_reg = &m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4];
385   UINT32 *pzab_reg   = &m_bgram[(linebank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; // pri, zoom, alpha, bank
388386
389387// now, for each scanline, check priority,
390388// extract the relevant scanline from the bitmap, after applying per-scanline vscroll,
r20973r20974
414412            int tilemap_scanline = (scanline - scrolly + 0x400) % 0x200;
415413
416414            // render reelvant tiles to temp bitmap, assume bank changes infrequently/never. render alpha as per-pen
417            cache_bitmap(tilemap_scanline, state, gfx, size, tilebank, alpha, last_bank);
415            cache_bitmap(tilemap_scanline, gfx, size, tilebank, alpha, last_bank);
418416
419417            /* zoomy and 'wibbly' effects - extract an entire row from tilemap */
420418            g_profiler.start(PROFILER_USER2);
421419            UINT32 tilemap_line[32 * 16];
422420            UINT32 scr_line[64 * 8];
423            extract_scanline32(state->m_bg_bitmap, 0, tilemap_scanline, width, tilemap_line);
421            extract_scanline32(m_bg_bitmap, 0, tilemap_scanline, width, tilemap_line);
424422            g_profiler.stop();
425423
426424            /* slow bit, needs optimising. apply scrollx and zoomx by assembling scanline from row */
427425            g_profiler.start(PROFILER_USER3);
428426            if(zoom) {
429               int step = state->m_bg_zoom[zoom];
427               int step = m_bg_zoom[zoom];
430428               int jj = 0x400 << 10; // ensure +ve for mod
431429               for(int ii = 0; ii < scr_width; ii++) {
432430                  scr_line[ii] = tilemap_line[((jj>>10) - scrollx) % width];
r20973r20974
461459}
462460
463461/* 3 BG layers, with priority */
464static void draw_background( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
462void psikyosh_state::draw_background( bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
465463{
466   psikyosh_state *state = machine.driver_data<psikyosh_state>();
467464   int i;
468465
469466#ifdef DEBUG_KEYS
r20973r20974
471468   bool lay_debug = false;
472469   for (i = 0; i <= 3; i++)
473470   {
474      if(machine.input().code_pressed(lay_keys[i])) {
471      if(machine().input().code_pressed(lay_keys[i])) {
475472         lay_debug = true;
476473      }
477474   }
r20973r20974
481478   for (i = 0; i <= 3; i++)
482479   {
483480#ifdef DEBUG_KEYS
484      if(lay_debug && !machine.input().code_pressed(lay_keys[i]))
481      if(lay_debug && !machine().input().code_pressed(lay_keys[i]))
485482         continue;
486483#endif
487484
r20973r20974
490487
491488      if(BG_LINE(i)) {
492489         /* per-line alpha, scroll, zoom etc. check the priority for the first scanline */
493         draw_bglayerscroll(machine, i, bitmap, cliprect, req_pri);
490         draw_bglayerscroll(i, bitmap, cliprect, req_pri);
494491      }
495492      else {
496493         /* not per-line alpha, scroll, zoom etc. */
497         draw_bglayer(machine, i, bitmap, cliprect, req_pri);
494         draw_bglayer(i, bitmap, cliprect, req_pri);
498495      }
499496   }
500497}
r20973r20974
508505/* sx and sy is top-left of entire sprite regardless of flip */
509506/* Note that Level 5-4 of sbomberb boss is perfect! (Alpha blended zoomed) as well as S1945II logo */
510507/* pixel is only plotted if z is >= priority_buffer[y][x] */
511static void psikyosh_drawgfxzoom( running_machine &machine,
512      bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
508void psikyosh_state:: psikyosh_drawgfxzoom( bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
513509      UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
514510      int alpha, int zoomx, int zoomy, int wide, int high, UINT32 z)
515511{
516   psikyosh_state *state = machine.driver_data<psikyosh_state>();
517   UINT8 *alphatable = state->m_alphatable;
512   UINT8 *alphatable = m_alphatable;
518513   rectangle myclip; /* Clip to screen boundaries */
519514   int code_offset = 0;
520515   int xtile, ytile, xpixel, ypixel;
r20973r20974
602597                     {
603598                        const UINT8 *source = code_base + (y_index) * gfx->rowbytes() + x_index_base;
604599                        UINT32 *dest = &dest_bmp.pix32(sy, sx);
605                        UINT16 *pri = &state->m_z_bitmap.pix16(sy, sx);
600                        UINT16 *pri = &m_z_bitmap.pix16(sy, sx);
606601                        int src_modulo = yinc * gfx->rowbytes() - xinc * (ex - sx);
607602                        int dst_modulo = dest_bmp.rowpixels() - (ex - sx);
608603
r20973r20974
661656                     {
662657                        const UINT8 *source = code_base + y_index * gfx->rowbytes() + x_index_base;
663658                        UINT32 *dest = &dest_bmp.pix32(sy, sx);
664                        UINT16 *pri = &state->m_z_bitmap.pix16(sy, sx);
659                        UINT16 *pri = &m_z_bitmap.pix16(sy, sx);
665660                        int src_modulo = yinc * gfx->rowbytes() - xinc * (ex - sx);
666661                        int dst_modulo = dest_bmp.rowpixels() - (ex - sx);
667662
r20973r20974
721716                     {
722717                        const UINT8 *source = code_base + y_index * gfx->rowbytes() + x_index_base;
723718                        UINT32 *dest = &dest_bmp.pix32(sy, sx);
724                        UINT16 *pri = &state->m_z_bitmap.pix16(sy, sx);
719                        UINT16 *pri = &m_z_bitmap.pix16(sy, sx);
725720                        int src_modulo = yinc * gfx->rowbytes() - xinc * (ex - sx);
726721                        int dst_modulo = dest_bmp.rowpixels() - (ex - sx);
727722
r20973r20974
798793            for (ypixel = 0; ypixel < gfx->height(); ypixel++)
799794            {
800795               const UINT8 *source = code_base + ypixel * gfx->rowbytes();
801               UINT8 *dest = &state->m_zoom_bitmap.pix8(ypixel + ytile*gfx->height());
796               UINT8 *dest = &m_zoom_bitmap.pix8(ypixel + ytile*gfx->height());
802797
803798               for (xpixel = 0; xpixel < gfx->width(); xpixel++)
804799               {
r20973r20974
873868                  {
874869                     for (y = sy; y < ey; y++)
875870                     {
876                        UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10);
871                        UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10);
877872                        UINT32 *dest = &dest_bmp.pix32(y);
878                        UINT16 *pri = &state->m_z_bitmap.pix16(y);
873                        UINT16 *pri = &m_z_bitmap.pix16(y);
879874
880875                        int x, x_index = x_index_base;
881876                        for (x = sx; x < ex; x++)
r20973r20974
899894                  {
900895                     for (y = sy; y < ey; y++)
901896                     {
902                        UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10);
897                        UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10);
903898                        UINT32 *dest = &dest_bmp.pix32(y);
904899
905900                        int x, x_index = x_index_base;
r20973r20974
923918                  {
924919                     for (y = sy; y < ey; y++)
925920                     {
926                        UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10);
921                        UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10);
927922                        UINT32 *dest = &dest_bmp.pix32(y);
928                        UINT16 *pri = &state->m_z_bitmap.pix16(y);
923                        UINT16 *pri = &m_z_bitmap.pix16(y);
929924
930925                        int x, x_index = x_index_base;
931926                        for (x = sx; x < ex; x++)
r20973r20974
949944                  {
950945                     for (y = sy; y < ey; y++)
951946                     {
952                        UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10);
947                        UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10);
953948                        UINT32 *dest = &dest_bmp.pix32(y);
954949
955950                        int x, x_index = x_index_base;
r20973r20974
972967                  {
973968                     for (y = sy; y < ey; y++)
974969                     {
975                        UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10);
970                        UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10);
976971                        UINT32 *dest = &dest_bmp.pix32(y);
977                        UINT16 *pri = &state->m_z_bitmap.pix16(y);
972                        UINT16 *pri = &m_z_bitmap.pix16(y);
978973
979974                        int x, x_index = x_index_base;
980975                        for (x = sx; x < ex; x++)
r20973r20974
1002997                  {
1003998                     for (y = sy; y < ey; y++)
1004999                     {
1005                        UINT8 *source = &state->m_zoom_bitmap.pix8(y_index >> 10);
1000                        UINT8 *source = &m_zoom_bitmap.pix8(y_index >> 10);
10061001                        UINT32 *dest = &dest_bmp.pix32(y);
10071002
10081003                        int x, x_index = x_index_base;
r20973r20974
10311026}
10321027
10331028
1034static void draw_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri)
1029void psikyosh_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri)
10351030{
10361031   /*- Sprite Format 0x0000 - 0x37ff -**
10371032
r20973r20974
10701065#ifdef DEBUG_KEYS
10711066   for (int i = 0; i <= 3; i++)
10721067   {
1073      if(machine.input().code_pressed(spr_keys[i])) {
1068      if(machine().input().code_pressed(spr_keys[i])) {
10741069         spr_debug = true;
10751070      }
10761071   }
10771072#endif
10781073
10791074
1080   psikyosh_state *state = machine.driver_data<psikyosh_state>();
10811075   gfx_element *gfx;
1082   UINT32 *src = state->m_spriteram->buffer(); /* Use buffered spriteram */
1076   UINT32 *src = m_spriteram->buffer(); /* Use buffered spriteram */
10831077   UINT16 *list = (UINT16 *)src + 0x3800 / 2;
10841078   UINT16 listlen = 0x800/2;
1085   UINT16 *zoom_table = (UINT16 *)state->m_zoomram.target();
1086   UINT8  *alpha_table = (UINT8 *)&(state->m_vidregs[0]);
1079   UINT16 *zoom_table = (UINT16 *)m_zoomram.target();
1080   UINT8  *alpha_table = (UINT8 *)&(m_vidregs[0]);
10871081
10881082   UINT16 listcntr = 0;
10891083   while (listcntr < listlen)
r20973r20974
11261120         alphamap = (alpha_table[BYTE4_XOR_BE(alpha)] & 0x80)? 1:0;
11271121         alpha = alpha_table[BYTE4_XOR_BE(alpha)] & 0x3f;
11281122
1129         gfx = dpth ? machine.gfx[1] : machine.gfx[0];
1123         gfx = dpth ? machine().gfx[1] : machine().gfx[0];
11301124
11311125         if (alphamap) /* alpha values are per-pen */
11321126            alpha = -1;
11331127         else
11341128            alpha = pal6bit(0x3f - alpha); /* 0x3f-0x00 maps to 0x00-0xff */
11351129
1136         if(!spr_debug || machine.input().code_pressed(spr_keys[spr_pri]))
1130         if(!spr_debug || machine().input().code_pressed(spr_keys[spr_pri]))
11371131         {
11381132            /* start drawing */
11391133            if (zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)]) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */
11401134            {
1141               psikyosh_drawgfxzoom(machine, bitmap, cliprect, gfx, tnum, colr, flpx, flpy, xpos, ypos, alpha,
1135               psikyosh_drawgfxzoom(bitmap, cliprect, gfx, tnum, colr, flpx, flpy, xpos, ypos, alpha,
11421136                              (UINT32)zoom_table[BYTE_XOR_BE(zoomx)], (UINT32)zoom_table[BYTE_XOR_BE(zoomy)], wide, high, listcntr);
11431137            }
11441138            /* end drawing */
r20973r20974
11511145}
11521146
11531147
1154static void psikyosh_prelineblend( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect )
1148void psikyosh_state::psikyosh_prelineblend( bitmap_rgb32 &bitmap, const rectangle &cliprect )
11551149{
11561150   /* There are 224 values for pre-lineblending. Using one for every row currently */
11571151   /* I suspect that it should be blended against black by the amount specified as
11581152      gnbarich sets the 0x000000ff to 0x7f in test mode whilst the others use 0x80.
11591153      tgm2 sets it to 0x00 on warning screen. Likely has no effect. */
1160   psikyosh_state *state = machine.driver_data<psikyosh_state>();
11611154   UINT32 *dstline;
1162   int bank = (state->m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (0x4000) except for daraku/soldivid */
1163   UINT32 *linefill = &state->m_bgram[(bank * 0x800) / 4 - 0x4000 / 4]; /* Per row */
1155   int bank = (m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (0x4000) except for daraku/soldivid */
1156   UINT32 *linefill = &m_bgram[(bank * 0x800) / 4 - 0x4000 / 4]; /* Per row */
11641157   int x, y;
11651158
11661159   assert(bitmap.bpp() == 32);
r20973r20974
11771170}
11781171
11791172
1180static void psikyosh_postlineblend( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
1173void psikyosh_state::psikyosh_postlineblend( bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT8 req_pri )
11811174{
11821175   /* There are 224 values for post-lineblending. Using one for every row currently */
1183   psikyosh_state *state = machine.driver_data<psikyosh_state>();
11841176   UINT32 *dstline;
1185   int bank = (state->m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (i.e. 0x4000) except for daraku/soldivid */
1186   UINT32 *lineblend = &state->m_bgram[(bank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; /* Per row */
1177   int bank = (m_vidregs[7] & 0xff000000) >> 24; /* bank is always 8 (i.e. 0x4000) except for daraku/soldivid */
1178   UINT32 *lineblend = &m_bgram[(bank * 0x800) / 4 - 0x4000 / 4 + 0x400 / 4]; /* Per row */
11871179   int x, y;
11881180
11891181   assert(bitmap.bpp() == 32);
11901182
1191   if ((state->m_vidregs[2] & 0xf) != req_pri) {
1183   if ((m_vidregs[2] & 0xf) != req_pri) {
11921184      return;
11931185   }
11941186
r20973r20974
12801272
12811273   m_z_bitmap.fill(0, cliprect); /* z-buffer */
12821274
1283   psikyosh_prelineblend(machine(), bitmap, cliprect); // fills screen
1275   psikyosh_prelineblend(bitmap, cliprect); // fills screen
12841276   for (i = 0; i <= 7; i++)
12851277   {
12861278      if(!pri_debug || machine().input().code_pressed(pri_keys[i]))
12871279      {
12881280         if(sprites) {
1289            draw_sprites(machine(), bitmap, cliprect, i); // When same priority bg's have higher pri
1281            draw_sprites(bitmap, cliprect, i); // When same priority bg's have higher pri
12901282         }
12911283         if(backgrounds) {
1292            draw_background(machine(), bitmap, cliprect, i);
1284            draw_background(bitmap, cliprect, i);
12931285         }
1294         psikyosh_postlineblend(machine(), bitmap, cliprect, i); // assume this has highest priority at same priority level
1286         psikyosh_postlineblend(bitmap, cliprect, i); // assume this has highest priority at same priority level
12951287      }
12961288   }
12971289   return 0;
trunk/src/mame/video/pushman.c
r20973r20974
7979
8080***************************************************************************/
8181
82static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
82void pushman_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
8383{
84   pushman_state *state = machine.driver_data<pushman_state>();
85   UINT16 *spriteram = state->m_spriteram;
84   UINT16 *spriteram = m_spriteram;
8685   int offs, x, y, color, sprite, flipx, flipy;
8786
8887   for (offs = 0x0800 - 4; offs >=0; offs -= 4)
r20973r20974
101100      flipx = spriteram[offs + 1] & 2;
102101      flipy = spriteram[offs + 1] & 1;    /* flip y untested */
103102
104      if (state->flip_screen())
103      if (flip_screen())
105104      {
106105         x = 240 - x;
107106         y = 240 - y;
r20973r20974
109108         flipy = !flipy;
110109      }
111110
112      drawgfx_transpen(bitmap,cliprect,machine.gfx[1], sprite,
111      drawgfx_transpen(bitmap,cliprect,machine().gfx[1], sprite,
113112            color, flipx, flipy, x, y, 15);
114113   }
115114}
r20973r20974
121120   m_bg_tilemap->set_scrolly(0, 0xf00 - m_control[1]);
122121
123122   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
124   draw_sprites(machine(), bitmap, cliprect);
123   draw_sprites(bitmap, cliprect);
125124   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
126125   return 0;
127126}
trunk/src/mame/video/pitnrun.c
r20973r20974
9494   machine().tilemap().mark_all_dirty();
9595}
9696
97static void pitnrun_spotlights(running_machine &machine)
97void pitnrun_state::pitnrun_spotlights()
9898{
99   pitnrun_state *state = machine.driver_data<pitnrun_state>();
10099   int x,y,i,b,datapix;
101   UINT8 *ROM = state->memregion("user1")->base();
100   UINT8 *ROM = memregion("user1")->base();
102101   for(i=0;i<4;i++)
103102      for(y=0;y<128;y++)
104103      for(x=0;x<16;x++)
r20973r20974
106105      datapix=ROM[128*16*i+x+y*16];
107106      for(b=0;b<8;b++)
108107      {
109         state->m_tmp_bitmap[i]->pix16(y, x*8+(7-b)) = (datapix&1);
108         m_tmp_bitmap[i]->pix16(y, x*8+(7-b)) = (datapix&1);
110109         datapix>>=1;
111110      }
112111      }
r20973r20974
169168   m_tmp_bitmap[1] = auto_bitmap_ind16_alloc(machine(),128,128);
170169   m_tmp_bitmap[2] = auto_bitmap_ind16_alloc(machine(),128,128);
171170   m_tmp_bitmap[3] = auto_bitmap_ind16_alloc(machine(),128,128);
172   pitnrun_spotlights(machine());
171   pitnrun_spotlights();
173172}
174173
175static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
174void pitnrun_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
176175{
177   pitnrun_state *state = machine.driver_data<pitnrun_state>();
178   UINT8 *spriteram = state->m_spriteram;
176   UINT8 *spriteram = m_spriteram;
179177   int sx, sy, flipx, flipy, offs,pal;
180178
181179   for (offs = 0 ; offs < 0x100; offs+=4)
r20973r20974
187185      flipy = (spriteram[offs+1]&0x80)>>7;
188186      flipx = (spriteram[offs+1]&0x40)>>6;
189187
190      if (state->flip_screen_x())
188      if (flip_screen_x())
191189      {
192190         sx = 256 - sx;
193191         flipx = !flipx;
194192      }
195      if (state->flip_screen_y())
193      if (flip_screen_y())
196194      {
197195         sy = 240 - sy;
198196         flipy = !flipy;
199197      }
200198
201      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
199      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
202200         (spriteram[offs+1]&0x3f)+((spriteram[offs+2]&0x80)>>1)+((spriteram[offs+2]&0x40)<<1),
203201         pal,
204202         flipx,flipy,
r20973r20974
253251      m_bg->draw(bitmap, myclip, 0,0);
254252   }
255253
256   draw_sprites(machine(),bitmap,myclip);
254   draw_sprites(bitmap,myclip);
257255
258256   if(m_ha&4)
259257      copybitmap_trans(bitmap,*m_tmp_bitmap[m_ha&3],flip_screen_x(),flip_screen_y(),dx,dy,myclip, 1);
trunk/src/mame/video/pandoras.c
r20973r20974
147147
148148***************************************************************************/
149149
150static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* sr )
150void pandoras_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8* sr )
151151{
152152   int offs;
153153
r20973r20974
159159      int nflipx = sr[offs + 3] & 0x40;
160160      int nflipy = sr[offs + 3] & 0x80;
161161
162      drawgfx_transmask(bitmap,cliprect,machine.gfx[0],
162      drawgfx_transmask(bitmap,cliprect,machine().gfx[0],
163163         sr[offs + 2],
164164         color,
165165         !nflipx,!nflipy,
166166         sx,sy,
167         colortable_get_transpen_mask(machine.colortable, machine.gfx[0], color, 0));
167         colortable_get_transpen_mask(machine().colortable, machine().gfx[0], color, 0));
168168   }
169169}
170170
171171UINT32 pandoras_state::screen_update_pandoras(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
172172{
173173   m_layer0->draw(bitmap, cliprect, 1 ,0);
174   draw_sprites(machine(), bitmap, cliprect, &m_spriteram[0x800] );
174   draw_sprites(bitmap, cliprect, &m_spriteram[0x800] );
175175   m_layer0->draw(bitmap, cliprect, 0 ,0);
176176   return 0;
177177}
trunk/src/mame/video/pacman.c
r20973r20974
147147
148148***************************************************************************/
149149
150static void init_save_state(running_machine &machine)
150void pacman_state::init_save_state()
151151{
152   pacman_state *state = machine.driver_data<pacman_state>();
153   state_save_register_global(machine, state->m_charbank);
154   state_save_register_global(machine, state->m_spritebank);
155   state_save_register_global(machine, state->m_palettebank);
156   state_save_register_global(machine, state->m_colortablebank);
157   state_save_register_global(machine, state->m_flipscreen);
158   state_save_register_global(machine, state->m_bgpriority);
152   state_save_register_global(machine(), m_charbank);
153   state_save_register_global(machine(), m_spritebank);
154   state_save_register_global(machine(), m_palettebank);
155   state_save_register_global(machine(), m_colortablebank);
156   state_save_register_global(machine(), m_flipscreen);
157   state_save_register_global(machine(), m_bgpriority);
159158}
160159
161160
162161VIDEO_START_MEMBER(pacman_state,pacman)
163162{
164   init_save_state(machine());
163   init_save_state();
165164
166165   m_charbank = 0;
167166   m_spritebank = 0;
r20973r20974
316315
317316VIDEO_START_MEMBER(pacman_state,pengo)
318317{
319   init_save_state(machine());
318   init_save_state();
320319
321320   m_charbank = 0;
322321   m_spritebank = 0;
r20973r20974
382381
383382VIDEO_START_MEMBER(pacman_state,s2650games)
384383{
385   init_save_state(machine());
384   init_save_state();
386385
387386   m_charbank = 0;
388387   m_spritebank = 0;
r20973r20974
525524   SET_TILE_INFO_MEMBER(0,code,attr,0);
526525}
527526
528static void jrpacman_mark_tile_dirty( running_machine &machine, int offset )
527void pacman_state::jrpacman_mark_tile_dirty( int offset )
529528{
530   pacman_state *state = machine.driver_data<pacman_state>();
531529   if( offset < 0x20 )
532530   {
533531      /* line color - mark whole line as dirty */
534532      int i;
535533      for( i = 2 * 0x20; i < 56 * 0x20; i += 0x20 )
536534      {
537         state->m_bg_tilemap->mark_tile_dirty(offset + i );
535         m_bg_tilemap->mark_tile_dirty(offset + i );
538536      }
539537   }
540538   else if (offset < 1792)
541539   {
542540      /* tiles for playfield */
543      state->m_bg_tilemap->mark_tile_dirty(offset );
541      m_bg_tilemap->mark_tile_dirty(offset );
544542   }
545543   else
546544   {
547545      /* tiles & colors for top and bottom two rows */
548      state->m_bg_tilemap->mark_tile_dirty(offset & ~0x80 );
546      m_bg_tilemap->mark_tile_dirty(offset & ~0x80 );
549547   }
550548}
551549
552550VIDEO_START_MEMBER(pacman_state,jrpacman)
553551{
554   init_save_state(machine());
552   init_save_state();
555553
556554   m_charbank = 0;
557555   m_spritebank = 0;
r20973r20974
571569WRITE8_MEMBER(pacman_state::jrpacman_videoram_w)
572570{
573571   m_videoram[offset] = data;
574   jrpacman_mark_tile_dirty(machine(), offset);
572   jrpacman_mark_tile_dirty(offset);
575573}
576574
577575WRITE8_MEMBER(pacman_state::jrpacman_charbank_w)
trunk/src/mame/video/pastelg.c
r20973r20974
1010#include "includes/nb1413m3.h"
1111#include "includes/pastelg.h"
1212
13
14static void pastelg_vramflip(running_machine &machine);
15static void pastelg_gfxdraw(running_machine &machine);
16
17
1813/******************************************************************************
1914
2015
r20973r20974
5752
5853
5954******************************************************************************/
60int pastelg_blitter_src_addr_r(address_space &space)
55int pastelg_state::pastelg_blitter_src_addr_r(address_space &space)
6156{
62   pastelg_state *state = space.machine().driver_data<pastelg_state>();
63   return state->m_blitter_src_addr;
57   return m_blitter_src_addr;
6458}
6559
6660WRITE8_MEMBER(pastelg_state::pastelg_blitter_w)
r20973r20974
7468      case 4: m_blitter_sizex = data; break;
7569      case 5: m_blitter_sizey = data;
7670            /* writing here also starts the blit */
77            pastelg_gfxdraw(machine());
71            pastelg_gfxdraw();
7872            break;
7973      case 6: m_blitter_direction_x = (data & 0x01) ? 1 : 0;
8074            m_blitter_direction_y = (data & 0x02) ? 1 : 0;
8175            m_flipscreen = (data & 0x04) ? 0 : 1;
8276            m_dispflag = (data & 0x08) ? 0 : 1;
83            pastelg_vramflip(machine());
77            pastelg_vramflip();
8478            break;
8579   }
8680}
r20973r20974
126120
127121
128122******************************************************************************/
129static void pastelg_vramflip(running_machine &machine)
123void pastelg_state::pastelg_vramflip()
130124{
131   pastelg_state *state = machine.driver_data<pastelg_state>();
132125   int x, y;
133126   UINT8 color1, color2;
134   int width = machine.primary_screen->width();
135   int height = machine.primary_screen->height();
127   int width = machine().primary_screen->width();
128   int height = machine().primary_screen->height();
136129
137   if (state->m_flipscreen == state->m_flipscreen_old) return;
130   if (m_flipscreen == m_flipscreen_old) return;
138131
139132   for (y = 0; y < height; y++)
140133   {
141134      for (x = 0; x < width; x++)
142135      {
143         color1 = state->m_videoram[(y * width) + x];
144         color2 = state->m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)];
145         state->m_videoram[(y * width) + x] = color2;
146         state->m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)] = color1;
136         color1 = m_videoram[(y * width) + x];
137         color2 = m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)];
138         m_videoram[(y * width) + x] = color2;
139         m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)] = color1;
147140      }
148141   }
149142
150   state->m_flipscreen_old = state->m_flipscreen;
143   m_flipscreen_old = m_flipscreen;
151144}
152145
153146TIMER_CALLBACK_MEMBER(pastelg_state::blitter_timer_callback)
r20973r20974
155148   nb1413m3_busyflag = 1;
156149}
157150
158static void pastelg_gfxdraw(running_machine &machine)
151void pastelg_state::pastelg_gfxdraw()
159152{
160   pastelg_state *state = machine.driver_data<pastelg_state>();
161   UINT8 *GFX = state->memregion("gfx1")->base();
162   int width = machine.primary_screen->width();
153   UINT8 *GFX = memregion("gfx1")->base();
154   int width = machine().primary_screen->width();
163155
164156   int x, y;
165157   int dx, dy;
r20973r20974
174166
175167   nb1413m3_busyctr = 0;
176168
177   startx = state->m_blitter_destx + state->m_blitter_sizex;
178   starty = state->m_blitter_desty + state->m_blitter_sizey;
169   startx = m_blitter_destx + m_blitter_sizex;
170   starty = m_blitter_desty + m_blitter_sizey;
179171
180172
181   if (state->m_blitter_direction_x)
173   if (m_blitter_direction_x)
182174   {
183      if (state->m_blitter_sizex&0x80) sizex = 0xff-state->m_blitter_sizex;
184      else sizex=state->m_blitter_sizex;
175      if (m_blitter_sizex&0x80) sizex = 0xff-m_blitter_sizex;
176      else sizex=m_blitter_sizex;
185177      incx = 1;
186178   }
187179   else
188180   {
189      sizex = state->m_blitter_sizex;
181      sizex = m_blitter_sizex;
190182      incx = -1;
191183   }
192184
193   if (state->m_blitter_direction_y)
185   if (m_blitter_direction_y)
194186   {
195      if (state->m_blitter_sizey&0x80) sizey = 0xff-state->m_blitter_sizey;
196      else sizey=state->m_blitter_sizey;
187      if (m_blitter_sizey&0x80) sizey = 0xff-m_blitter_sizey;
188      else sizey=m_blitter_sizey;
197189      incy = 1;
198190   }
199191   else
200192   {
201      sizey = state->m_blitter_sizey;
193      sizey = m_blitter_sizey;
202194      incy = -1;
203195   }
204196
205   gfxlen = machine.root_device().memregion("gfx1")->bytes();
206   gfxaddr = (state->m_gfxrom << 16) + state->m_blitter_src_addr;
197   gfxlen = machine().root_device().memregion("gfx1")->bytes();
198   gfxaddr = (m_gfxrom << 16) + m_blitter_src_addr;
207199
208200   readflag = 0;
209201
r20973r20974
216208
217209      for (ctrx = sizex; ctrx >= 0; ctrx--)
218210      {
219         gfxaddr = (state->m_gfxrom << 16) + ((state->m_blitter_src_addr + count));
211         gfxaddr = (m_gfxrom << 16) + ((m_blitter_src_addr + count));
220212
221213         if ((gfxaddr > (gfxlen - 1)))
222214         {
r20973r20974
231223         dx = x & 0xff;
232224         dy = y & 0xff;
233225
234         if (state->m_flipscreen)
226         if (m_flipscreen)
235227         {
236228            dx ^= 0xff;
237229            dy ^= 0xff;
r20973r20974
251243
252244         readflag ^= 1;
253245
254         if (state->m_clut[color] & 0xf0)
246         if (m_clut[color] & 0xf0)
255247         {
256248            if (color)
257249            {
258               color = ((state->m_palbank * 0x10) + color);
259               state->m_videoram[(dy * width) + dx] = color;
250               color = ((m_palbank * 0x10) + color);
251               m_videoram[(dy * width) + dx] = color;
260252            }
261253         }
262254         else
263255         {
264            if(state->m_clut[color] != 0)
256            if(m_clut[color] != 0)
265257            {
266               color = ((state->m_palbank * 0x10) + state->m_clut[color]);
267               state->m_videoram[(dy * width) + dx] = color;
258               color = ((m_palbank * 0x10) + m_clut[color]);
259               m_videoram[(dy * width) + dx] = color;
268260            }
269261         }
270262
r20973r20974
276268   }
277269
278270   nb1413m3_busyflag = 0;
279   machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(pastelg_state::blitter_timer_callback),state));
271   machine().scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, timer_expired_delegate(FUNC(pastelg_state::blitter_timer_callback),this));
280272}
281273
282274/******************************************************************************
trunk/src/mame/video/pooyan.c
r20973r20974
154154 *
155155 *************************************/
156156
157static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
157void pooyan_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
158158{
159   pooyan_state *state = machine.driver_data<pooyan_state>();
160   UINT8 *spriteram = state->m_spriteram;
161   UINT8 *spriteram_2 = state->m_spriteram2;
159   UINT8 *spriteram = m_spriteram;
160   UINT8 *spriteram_2 = m_spriteram2;
162161   int offs;
163162
164163   for (offs = 0x10; offs < 0x40; offs += 2)
r20973r20974
172171      int flipy = spriteram_2[offs] & 0x80;
173172
174173      drawgfx_transmask(bitmap,cliprect,
175         machine.gfx[1],
174         machine().gfx[1],
176175         code,
177176         color,
178177         flipx, flipy,
179178         sx, sy,
180         colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 0));
179         colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 0));
181180   }
182181}
183182
r20973r20974
192191UINT32 pooyan_state::screen_update_pooyan(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
193192{
194193   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
195   draw_sprites(machine(), bitmap, cliprect);
194   draw_sprites(bitmap, cliprect);
196195   return 0;
197196}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team