Previous 199869 Revisions Next

r20747 Tuesday 5th February, 2013 at 15:23:44 UTC by Miodrag Milanović
Modernization of drivers part 2 (no whatsnew)
[src/mame/drivers]cabal.c ccastles.c cdi.c centiped.c cischeat.c cloud9.c compgolf.c cps3.c crbaloon.c crospang.c crshrace.c cvs.c galaxia.c
[src/mame/includes]cabal.h canyon.h capbowl.h carpolo.h cbasebal.h cbuster.h ccastles.h cchasm.h cclimber.h cdi.h centiped.h chaknpop.h champbas.h changela.h cheekyms.h circus.h circusc.h cischeat.h citycon.h cloak.h cloud9.h clshroad.h cninja.h combatsc.h commando.h compgolf.h contra.h cop01.h cosmic.h cps3.h crbaloon.h crgolf.h crospang.h crshrace.h cvs.h cyberbal.h galaxia.h
[src/mame/machine]carpolo.c cclimber.c chaknpop.c
[src/mame/video]cabal.c canyon.c capbowl.c carpolo.c cbasebal.c cbuster.c ccastles.c cchasm.c cclimber.c centiped.c chaknpop.c champbas.c changela.c cheekyms.c circus.c circusc.c cischeat.c citycon.c cloak.c cloud9.c clshroad.c cninja.c combatsc.c commando.c compgolf.c contra.c cop01.c cosmic.c crbaloon.c crgolf.c crshrace.c cvs.c cyberbal.c galaxia.c

trunk/src/mame/machine/carpolo.c
r20746r20747
9494}
9595
9696
97void carpolo_generate_ball_screen_interrupt(running_machine &machine, UINT8 cause)
97void carpolo_state::carpolo_generate_ball_screen_interrupt(UINT8 cause)
9898{
99   carpolo_state *state = machine.driver_data<carpolo_state>();
100   state->m_ball_screen_collision_cause = cause;
99   m_ball_screen_collision_cause = cause;
101100
102   ttl74148_input_line_w(state->m_ttl74148_3s, BALL_SCREEN_PRIORITY_LINE, 0);
103   ttl74148_update(state->m_ttl74148_3s);
101   ttl74148_input_line_w(m_ttl74148_3s, BALL_SCREEN_PRIORITY_LINE, 0);
102   ttl74148_update(m_ttl74148_3s);
104103}
105104
106void carpolo_generate_car_car_interrupt(running_machine &machine, int car1, int car2)
105void carpolo_state::carpolo_generate_car_car_interrupt(int car1, int car2)
107106{
108   carpolo_state *state = machine.driver_data<carpolo_state>();
109   state->m_car_car_collision_cause = ~((1 << (3 - car1)) | (1 << (3 - car2)));
107   m_car_car_collision_cause = ~((1 << (3 - car1)) | (1 << (3 - car2)));
110108
111   ttl74148_input_line_w(state->m_ttl74148_3s, CAR_CAR_PRIORITY_LINE, 0);
112   ttl74148_update(state->m_ttl74148_3s);
109   ttl74148_input_line_w(m_ttl74148_3s, CAR_CAR_PRIORITY_LINE, 0);
110   ttl74148_update(m_ttl74148_3s);
113111}
114112
115void carpolo_generate_car_goal_interrupt(running_machine &machine, int car, int right_goal)
113void carpolo_state::carpolo_generate_car_goal_interrupt(int car, int right_goal)
116114{
117   carpolo_state *state = machine.driver_data<carpolo_state>();
118   state->m_car_goal_collision_cause = car | (right_goal ? 0x08 : 0x00);
115   m_car_goal_collision_cause = car | (right_goal ? 0x08 : 0x00);
119116
120   ttl74148_input_line_w(state->m_ttl74148_3s, CAR_GOAL_PRIORITY_LINE, 0);
121   ttl74148_update(state->m_ttl74148_3s);
117   ttl74148_input_line_w(m_ttl74148_3s, CAR_GOAL_PRIORITY_LINE, 0);
118   ttl74148_update(m_ttl74148_3s);
122119}
123120
124void carpolo_generate_car_ball_interrupt(running_machine &machine, int car, int car_x, int car_y)
121void carpolo_state::carpolo_generate_car_ball_interrupt(int car, int car_x, int car_y)
125122{
126   carpolo_state *state = machine.driver_data<carpolo_state>();
127   state->m_car_ball_collision_cause = car;
128   state->m_car_ball_collision_x = car_x;
129   state->m_car_ball_collision_y = car_y;
123   m_car_ball_collision_cause = car;
124   m_car_ball_collision_x = car_x;
125   m_car_ball_collision_y = car_y;
130126
131   state->m_priority_0_extension = CAR_BALL_EXTRA_BITS;
127   m_priority_0_extension = CAR_BALL_EXTRA_BITS;
132128
133   ttl74148_input_line_w(state->m_ttl74148_3s, PRI0_PRIORTITY_LINE, 0);
134   ttl74148_update(state->m_ttl74148_3s);
129   ttl74148_input_line_w(m_ttl74148_3s, PRI0_PRIORTITY_LINE, 0);
130   ttl74148_update(m_ttl74148_3s);
135131}
136132
137void carpolo_generate_car_border_interrupt(running_machine &machine, int car, int horizontal_border)
133void carpolo_state::carpolo_generate_car_border_interrupt(int car, int horizontal_border)
138134{
139   carpolo_state *state = machine.driver_data<carpolo_state>();
140   state->m_car_border_collision_cause = car | (horizontal_border ? 0x04 : 0x00);
135   m_car_border_collision_cause = car | (horizontal_border ? 0x04 : 0x00);
141136
142   state->m_priority_0_extension = CAR_BORDER_EXTRA_BITS;
137   m_priority_0_extension = CAR_BORDER_EXTRA_BITS;
143138
144   ttl74148_input_line_w(state->m_ttl74148_3s, PRI0_PRIORTITY_LINE, 0);
145   ttl74148_update(state->m_ttl74148_3s);
139   ttl74148_input_line_w(m_ttl74148_3s, PRI0_PRIORTITY_LINE, 0);
140   ttl74148_update(m_ttl74148_3s);
146141}
147142
148143
trunk/src/mame/machine/chaknpop.c
r20746r20747
4545   0x10, 0xfc, 0x3e, 0x01, 0x32, 0x5b, 0x81, 0xc9
4646};
4747
48static void mcu_update_seed( running_machine &machine, UINT8 data )
48void chaknpop_state::mcu_update_seed( UINT8 data )
4949{
50   chaknpop_state *state = machine.driver_data<chaknpop_state>();
5150
5251   if (!(data & 0x80))
5352   {
54      state->m_mcu_seed += 0x83;
55      state->m_mcu_seed = (state->m_mcu_seed & 0x80) | (state->m_mcu_seed >> 1);
53      m_mcu_seed += 0x83;
54      m_mcu_seed = (m_mcu_seed & 0x80) | (m_mcu_seed >> 1);
5655   }
5756
58   state->m_mcu_seed += 0x19;
57   m_mcu_seed += 0x19;
5958
60   //logerror("New seed: 0x%02x\n", state->m_mcu_seed);
59   //logerror("New seed: 0x%02x\n", m_mcu_seed);
6160}
6261
6362
r20746r20747
9493
9594   if (mcu_command < 0x08)
9695   {
97      mcu_update_seed(machine(), data);
96      mcu_update_seed(data);
9897
9998      m_mcu_result = mcu_data[m_mcu_select * 8 + mcu_command];
10099      m_mcu_result -= m_mcu_seed;
101100
102      mcu_update_seed(machine(), m_mcu_result);
101      mcu_update_seed(m_mcu_result);
103102
104103      logerror("%04x: MCU command 0x%02x, result 0x%02x\n", space.device().safe_pc(), mcu_command, m_mcu_result);
105104   }
106105   else if (mcu_command >= 0x28 && mcu_command <= 0x2a)
107106   {
108      mcu_update_seed(machine(), data);
107      mcu_update_seed(data);
109108
110109      m_mcu_result = m_mcu_ram[0x380 + mcu_command];
111110      m_mcu_result -= m_mcu_seed;
112111
113      mcu_update_seed(machine(), m_mcu_result);
112      mcu_update_seed(m_mcu_result);
114113
115114      logerror("%04x: MCU command 0x%02x, result 0x%02x\n", space.device().safe_pc(), mcu_command, m_mcu_result);
116115   }
117116   else if (mcu_command < 0x80)
118117   {
119      mcu_update_seed(machine(), data);
118      mcu_update_seed(data);
120119
121120      if (mcu_command >= 0x40 && mcu_command < 0x60)
122121      {
r20746r20747
127126   }
128127   else if (mcu_command == 0x9c|| mcu_command == 0xde)
129128   {
130      mcu_update_seed(machine(), data);
129      mcu_update_seed(data);
131130
132131      logerror("%04x: MCU command 0x%02x\n", space.device().safe_pc(), mcu_command);
133132   }
trunk/src/mame/machine/cclimber.c
r20746r20747
44/* set to 1 to fix protection check after bonus round (see notes in pacman.c driver) */
55#define CANNONB_HACK    0
66
7static void cclimber_decode(running_machine &machine, const UINT8 convtable[8][16])
7void cclimber_state::cclimber_decode(const UINT8 convtable[8][16])
88{
9   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
10   UINT8 *rom = machine.root_device().memregion("maincpu")->base();
11   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
9   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
10   UINT8 *rom = machine().root_device().memregion("maincpu")->base();
11   UINT8 *decrypt = auto_alloc_array(machine(), UINT8, 0x10000);
1212   int A;
1313
1414   space.set_decrypted_region(0x0000, 0xffff, decrypt);
r20746r20747
4545      {   -1,  -1,0x54,0x01,0x15,0x40,0x45,0x41,0x51,0x04,0x50,0x05,0x11,0x44,0x10,0x14 }
4646   };
4747
48   cclimber_decode(machine(), convtable);
48   cclimber_decode(convtable);
4949}
5050
5151DRIVER_INIT_MEMBER(cclimber_state,cclimberj)
r20746r20747
6262      { 0x55,0x50,0x15,0x10,0x01,0x04,0x41,0x44,0x45,0x40,0x05,0x00,0x11,0x14,0x51,0x54 },
6363   };
6464
65   cclimber_decode(machine(), convtable);
65   cclimber_decode(convtable);
6666}
6767
6868DRIVER_INIT_MEMBER(cclimber_state,ckongb)
r20746r20747
7777}
7878
7979#if CANNONB_HACK
80static void cannonb_patch(running_machine &machine)
80void ::cannonb_patch()
8181{
82   UINT8 *rom = machine.root_device().memregion("maincpu")->base();
82   UINT8 *rom = machine().root_device().memregion("maincpu")->base();
8383
8484   rom[0x2ba0] = 0x21;
8585   rom[0x2ba1] = 0xfb;
trunk/src/mame/includes/capbowl.h
r20746r20747
4343   UINT32 screen_update_capbowl(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
4444   INTERRUPT_GEN_MEMBER(capbowl_interrupt);
4545   TIMER_CALLBACK_MEMBER(capbowl_update);
46   inline rgb_t pen_for_pixel( UINT8 *src, UINT8 pix );
4647};
trunk/src/mame/includes/compgolf.h
r20746r20747
4242   virtual void video_start();
4343   virtual void palette_init();
4444   UINT32 screen_update_compgolf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
45   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
46   void compgolf_expand_bg();
4547};
trunk/src/mame/includes/circusc.h
r20746r20747
6060   virtual void palette_init();
6161   UINT32 screen_update_circusc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6262   INTERRUPT_GEN_MEMBER(vblank_irq);
63   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6364};
trunk/src/mame/includes/cbasebal.h
r20746r20747
4949   virtual void machine_reset();
5050   virtual void video_start();
5151   UINT32 screen_update_cbasebal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
52   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5253};
trunk/src/mame/includes/cninja.h
r20746r20747
7979   UINT32 screen_update_robocop2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8080   UINT32 screen_update_mutantf(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
8181   TIMER_DEVICE_CALLBACK_MEMBER(interrupt_gen);
82   void cninjabl_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
8283};
trunk/src/mame/includes/cbuster.h
r20746r20747
4949   virtual void machine_reset();
5050   virtual void video_start();
5151   UINT32 screen_update_twocrude(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
52   void update_24bitcol( int offset );
5253};
trunk/src/mame/includes/canyon.h
r20746r20747
4444   DECLARE_WRITE8_MEMBER(canyon_explode_w);
4545   DECLARE_WRITE8_MEMBER(canyon_attract_w);
4646   DECLARE_WRITE8_MEMBER(canyon_whistle_w);
47   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
48   void draw_bombs( bitmap_ind16 &bitmap, const rectangle &cliprect );
4749};
4850
4951
trunk/src/mame/includes/crbaloon.h
r20746r20747
4444   DECLARE_WRITE8_MEMBER(crbaloon_audio_set_music_freq);
4545   DECLARE_WRITE8_MEMBER(crbaloon_audio_set_music_enable);
4646   DECLARE_WRITE8_MEMBER(crbaloon_audio_set_laugh_enable);
47   UINT16 crbaloon_get_collision_address();
48   void crbaloon_set_clear_collision_address(int _crbaloon_collision_address_clear);
49   void draw_sprite_and_check_collision(bitmap_ind16 &bitmap);
50   void pc3092_reset(void);
51   void pc3092_update();
52   void pc3259_update(void);
4753};
4854
4955
r20746r20747
5359void crbaloon_audio_set_breath_enable(device_t *sn, int enabled);
5460void crbaloon_audio_set_appear_enable(device_t *sn, int enabled);
5561MACHINE_CONFIG_EXTERN( crbaloon_audio );
56
57/*----------- defined in video/crbaloon.c -----------*/
58UINT16 crbaloon_get_collision_address(running_machine &machine);
59void crbaloon_set_clear_collision_address(running_machine &machine, int _crbaloon_collision_address_clear);
trunk/src/mame/includes/cischeat.h
r20746r20747
8787   TIMER_DEVICE_CALLBACK_MEMBER(bigrun_scanline);
8888   TIMER_DEVICE_CALLBACK_MEMBER(scudhamm_scanline);
8989   TIMER_DEVICE_CALLBACK_MEMBER(armchamp2_scanline);
90   void prepare_shadows(cischeat_state *state);
91   inline void scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which);
92   void create_tilemaps();
93   void cischeat_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency);
94   void f1gpstar_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency);
95   void cischeat_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2);
96   void bigrun_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2);
97   void cischeat_untangle_sprites(const char *region);
9098};
trunk/src/mame/includes/centiped.h
r20746r20747
8080   UINT32 screen_update_milliped(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8181   UINT32 screen_update_warlords(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8282   TIMER_DEVICE_CALLBACK_MEMBER(generate_interrupt);
83   void init_penmask();
84   void init_common();
85   void milliped_set_color(offs_t offset, UINT8 data);
86   inline int read_trackball(int idx, int switch_port);
8387};
trunk/src/mame/includes/galaxia.h
r20746r20747
2929   UINT32 screen_update_galaxia(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3030   UINT32 screen_update_astrowar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3131   INTERRUPT_GEN_MEMBER(galaxia_interrupt);
32   void init_common();
3233};
trunk/src/mame/includes/crgolf.h
r20746r20747
5656   UINT32 screen_update_crgolf(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5757   TIMER_CALLBACK_MEMBER(main_to_sound_callback);
5858   TIMER_CALLBACK_MEMBER(sound_to_main_callback);
59   void get_pens( pen_t *pens );
5960};
6061
6162/*----------- defined in video/crgolf.c -----------*/
trunk/src/mame/includes/commando.h
r20746r20747
4848   virtual void video_start();
4949   UINT32 screen_update_commando(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5050   INTERRUPT_GEN_MEMBER(commando_interrupt);
51   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5152};
trunk/src/mame/includes/cabal.h
r20746r20747
3535   virtual void video_start();
3636   DECLARE_MACHINE_RESET(cabalbl);
3737   UINT32 screen_update_cabal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
38   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
39   void seibu_sound_bootleg(const char *cpu,int length);
3840};
trunk/src/mame/includes/cheekyms.h
r20746r20747
3737   virtual void palette_init();
3838   UINT32 screen_update_cheekyms(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3939   INTERRUPT_GEN_MEMBER(vblank_irq);
40   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, int flip );
4041};
trunk/src/mame/includes/cdi.h
r20746r20747
6868   DECLARE_MACHINE_RESET(quizrr42);
6969   UINT32 screen_update_cdimono1(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
7070   UINT32 screen_update_cdimono1_lcd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
71   INLINE void verboselog(int n_level, const char *s_fmt, ...);
7172};
7273
7374/*----------- debug defines -----------*/
trunk/src/mame/includes/circus.h
r20746r20747
4242   UINT32 screen_update_crash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4343   UINT32 screen_update_ripcord(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444   TIMER_DEVICE_CALLBACK_MEMBER(crash_scanline);
45   void draw_line( bitmap_ind16 &bitmap, const rectangle &cliprect, int x1, int y1, int x2, int y2, int dotted );
46   void draw_sprite_collision( bitmap_ind16 &bitmap, const rectangle &cliprect );
47   void circus_draw_fg( bitmap_ind16 &bitmap, const rectangle &cliprect );
48   void robotbwl_draw_box( bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y );
49   void robotbwl_draw_scoreboard( bitmap_ind16 &bitmap, const rectangle &cliprect );
50   void robotbwl_draw_bowling_alley( bitmap_ind16 &bitmap, const rectangle &cliprect );
51   void robotbwl_draw_ball( bitmap_ind16 &bitmap, const rectangle &cliprect );
52   void crash_draw_car( bitmap_ind16 &bitmap, const rectangle &cliprect );
4553};
4654/*----------- defined in audio/circus.c -----------*/
4755
trunk/src/mame/includes/cloud9.h
r20746r20747
6060   virtual void video_start();
6161   UINT32 screen_update_cloud9(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6262   TIMER_CALLBACK_MEMBER(clock_irq);
63   inline void cloud9_write_vram( UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba );
64   inline void bitmode_autoinc(  );
65   inline void schedule_next_irq(int curscanline);
6366};
trunk/src/mame/includes/cyberbal.h
r20746r20747
8383   void cyberbal_sound_reset();
8484   UINT32 update_one_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int index);
8585   void update_sound_68k_interrupts();
86   inline void set_palette_entry(int entry, UINT16 value);
8687};
trunk/src/mame/includes/cloak.h
r20746r20747
4141   TILE_GET_INFO_MEMBER(get_bg_tile_info);
4242   virtual void video_start();
4343   UINT32 screen_update_cloak(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
44   void set_pens();
45   void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);
46   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
4447};
trunk/src/mame/includes/combatsc.h
r20746r20747
8181   DECLARE_PALETTE_INIT(combatscb);
8282   UINT32 screen_update_combatsc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
8383   UINT32 screen_update_combatscb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
84   void set_pens(  );
85   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit, UINT32 pri_mask );
86   void bootleg_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit );
8487};
trunk/src/mame/includes/contra.h
r20746r20747
6262   virtual void palette_init();
6363   UINT32 screen_update_contra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6464   INTERRUPT_GEN_MEMBER(contra_interrupt);
65   void set_pens(  );
66   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int bank );
6567};
trunk/src/mame/includes/cps3.h
r20746r20747
108108   UINT32 screen_update_cps3(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
109109   INTERRUPT_GEN_MEMBER(cps3_vbl_interrupt);
110110   INTERRUPT_GEN_MEMBER(cps3_other_interrupt);
111   UINT16 rotate_left(UINT16 value, int n);
112   UINT16 rotxor(UINT16 val, UINT16 xorval);
113   UINT32 cps3_mask(UINT32 address, UINT32 key1, UINT32 key2);
114   void cps3_decrypt_bios();
115   void init_common(UINT32 key1, UINT32 key2, int altEncryption);
116   void cps3_set_mame_colours(int colournum, UINT16 data, UINT32 fadeval);
117   void cps3_draw_tilemapsprite_line(int tmnum, int drawline, bitmap_rgb32 &bitmap, const rectangle &cliprect );
118   UINT32 cps3_flashmain_r(address_space &space, int which, UINT32 offset, UINT32 mem_mask);
119   void cps3_flashmain_w(int which, UINT32 offset, UINT32 data, UINT32 mem_mask);
120   UINT32 process_byte( UINT8 real_byte, UINT32 destination, int max_length );
121   void cps3_do_char_dma( UINT32 real_source, UINT32 real_destination, UINT32 real_length );
122   UINT32 ProcessByte8(UINT8 b,UINT32 dst_offset);
123   void cps3_do_alt_char_dma( UINT32 src, UINT32 real_dest, UINT32 real_length );
124   void cps3_process_character_dma(UINT32 address);
125   void copy_from_nvram();
126   inline void cps3_drawgfxzoom(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
127      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
128      int transparency,int transparent_color,
129      int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask);
130   
111131};
112132
113133
trunk/src/mame/includes/cvs.h
r20746r20747
107107   UINT32 screen_update_cvs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
108108   INTERRUPT_GEN_MEMBER(cvs_main_cpu_interrupt);
109109   TIMER_CALLBACK_MEMBER(cvs_393hz_timer_cb);
110   void set_pens(  );
111   void cvs_scroll_stars(  );
112   void cvs_init_stars(  );
113   void cvs_update_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, const pen_t star_pen, bool update_always);
114   void start_393hz_timer();
110115};
111
112/*----------- defined in video/cvs.c -----------*/
113void cvs_init_stars( running_machine &machine );
114void cvs_scroll_stars( running_machine &machine );
115void cvs_update_stars(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const pen_t star_pen, bool update_always);
trunk/src/mame/includes/champbas.h
r20746r20747
6565   void screen_eof_champbas(screen_device &screen, bool state);
6666   INTERRUPT_GEN_MEMBER(vblank_irq);
6767   TIMER_CALLBACK_MEMBER(exctsccr_fm_callback);
68   void champbas_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
69   void exctsccr_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6870};
trunk/src/mame/includes/crshrace.h
r20746r20747
5858   virtual void video_start();
5959   UINT32 screen_update_crshrace(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6060   void screen_eof_crshrace(screen_device &screen, bool state);
61   void draw_bg( bitmap_ind16 &bitmap, const rectangle &cliprect );
62   void draw_fg(bitmap_ind16 &bitmap, const rectangle &cliprect);
63   void crshrace_patch_code( UINT16 offset );
6164};
trunk/src/mame/includes/clshroad.h
r20746r20747
3131   DECLARE_VIDEO_START(clshroad);
3232   DECLARE_PALETTE_INIT(clshroad);
3333   UINT32 screen_update_clshroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
34   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
3435};
trunk/src/mame/includes/carpolo.h
r20746r20747
8383   DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_1_q_cb);
8484   DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_2_q_cb);
8585
86   void remap_sprite_code(int bank, int code, int *remapped_code, int *flipy);
87   void normalize_coordinates(int *x1, int *y1, int *x2, int *y2);
88   int check_sprite_left_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only);
89   int check_sprite_right_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only);
90   int check_sprite_border_collision(UINT8 x1, UINT8 y1, int code1, int flipy1);
91   void carpolo_generate_ball_screen_interrupt(UINT8 cause);
92   void carpolo_generate_car_car_interrupt(int car1, int car2);
93   void carpolo_generate_car_goal_interrupt(int car, int right_goal);
94   void carpolo_generate_car_ball_interrupt(int car, int car_x, int car_y);
95   void carpolo_generate_car_border_interrupt(int car, int horizontal_border);
96   void draw_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect,
97                  UINT8 x, UINT8 y, int bank, int code, int col);
98   int check_sprite_sprite_collision(int x1, int y1, int code1, int flipy1,
99                              int x2, int y2, int code2, int flipy2,
100                              int *col_x, int *col_y);
101   
86102};
87103
88104
r20746r20747
92108extern const pia6821_interface carpolo_pia1_intf;
93109
94110void carpolo_74148_3s_cb(device_t *device);
95void carpolo_generate_car_car_interrupt(running_machine &machine, int car1, int car2);
96void carpolo_generate_ball_screen_interrupt(running_machine &machine, UINT8 cause);
97void carpolo_generate_car_goal_interrupt(running_machine &machine, int car, int right_goal);
98void carpolo_generate_car_ball_interrupt(running_machine &machine, int car, int car_x, int car_y);
99void carpolo_generate_car_border_interrupt(running_machine &machine, int car, int horizontal_border);
trunk/src/mame/includes/changela.h
r20746r20747
9292   INTERRUPT_GEN_MEMBER(chl_mcu_irq);
9393   TIMER_CALLBACK_MEMBER(changela_scanline_callback);
9494   TIMER_DEVICE_CALLBACK_MEMBER(changela_scanline);
95   void draw_obj0( bitmap_ind16 &bitmap, int sy );
96   void draw_obj1( bitmap_ind16 &bitmap );
97   void draw_river( bitmap_ind16 &bitmap, int sy );
98   void draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num );
9599};
trunk/src/mame/includes/crospang.h
r20746r20747
5050   virtual void machine_reset();
5151   virtual void video_start();
5252   UINT32 screen_update_crospang(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
53   void tumblepb_gfx1_rearrange();
5354};
trunk/src/mame/includes/cosmic.h
r20746r20747
7676   UINT32 screen_update_devzone(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7777   UINT32 screen_update_nomnlnd(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7878   TIMER_DEVICE_CALLBACK_MEMBER(panic_scanline);
79   void draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect );
80   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int extra_sprites );
81   void cosmica_draw_starfield( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
82   void devzone_draw_grid( bitmap_ind16 &bitmap, const rectangle &cliprect );
83   void nomnlnd_draw_background( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
7984};
trunk/src/mame/includes/ccastles.h
r20746r20747
6969   virtual void video_start();
7070   UINT32 screen_update_ccastles(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7171   TIMER_CALLBACK_MEMBER(clock_irq);
72   inline void ccastles_write_vram( UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba );
73   inline void bitmode_autoinc(  );
74   inline void schedule_next_irq( int curscanline );
7275};
trunk/src/mame/includes/cop01.h
r20746r20747
4747   virtual void video_start();
4848   virtual void palette_init();
4949   UINT32 screen_update_cop01(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
50   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5051};
trunk/src/mame/includes/cchasm.h
r20746r20747
3535   TIMER_CALLBACK_MEMBER(cchasm_refresh_end);
3636   DECLARE_WRITE_LINE_MEMBER(ctc_timer_1_w);
3737   DECLARE_WRITE_LINE_MEMBER(ctc_timer_2_w);
38   void cchasm_refresh ();
3839};
3940
4041/*----------- defined in audio/cchasm.c -----------*/
trunk/src/mame/includes/chaknpop.h
r20746r20747
5454   virtual void palette_init();
5555   UINT32 screen_update_chaknpop(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5656   void tx_tilemap_mark_all_dirty();
57   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
58   void draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect );
59   void mcu_update_seed( UINT8 data );
5760};
trunk/src/mame/includes/cclimber.h
r20746r20747
7272   UINT32 screen_update_yamato(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7373   UINT32 screen_update_toprollr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7474   INTERRUPT_GEN_MEMBER(vblank_irq);
75   void swimmer_set_background_pen();
76   void draw_playfield(bitmap_ind16 &bitmap, const rectangle &cliprect);
77   void cclimber_draw_bigsprite(bitmap_ind16 &bitmap, const rectangle &cliprect);
78   void toprollr_draw_bigsprite(bitmap_ind16 &bitmap, const rectangle &cliprect);
79   void cclimber_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx);
80   void toprollr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx);
81   void swimmer_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx);
82   void cclimber_decode(const UINT8 convtable[8][16]);
83   void cannonb_patch();
7584};
trunk/src/mame/includes/citycon.h
r20746r20747
4141   virtual void machine_reset();
4242   virtual void video_start();
4343   UINT32 screen_update_citycon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
44   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
45   inline void changecolor_RRRRGGGGBBBBxxxx( int color, int indx );
4446};
trunk/src/mame/video/contra.c
r20746r20747
5353}
5454
5555
56static void set_pens( running_machine &machine )
56void contra_state::set_pens(  )
5757{
58   contra_state *state = machine.driver_data<contra_state>();
5958   int i;
6059
6160   for (i = 0x00; i < 0x100; i += 2)
6261   {
63      UINT16 data = state->m_paletteram[i] | (state->m_paletteram[i | 1] << 8);
62      UINT16 data = m_paletteram[i] | (m_paletteram[i | 1] << 8);
6463
6564      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
6665
67      colortable_palette_set_color(machine.colortable, i >> 1, color);
66      colortable_palette_set_color(machine().colortable, i >> 1, color);
6867   }
6968}
7069
r20746r20747
283282
284283***************************************************************************/
285284
286static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int bank )
285void contra_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int bank )
287286{
288   contra_state *state = machine.driver_data<contra_state>();
289   device_t *k007121 = bank ? state->m_k007121_2 : state->m_k007121_1;
290   address_space &space = machine.driver_data()->generic_space();
287   device_t *k007121 = bank ? m_k007121_2 : m_k007121_1;
288   address_space &space = machine().driver_data()->generic_space();
291289   int base_color = (k007121_ctrlram_r(k007121, space, 6) & 0x30) * 2;
292290   const UINT8 *source;
293291
294292   if (bank == 0)
295      source = state->m_buffered_spriteram;
293      source = m_buffered_spriteram;
296294   else
297      source = state->m_buffered_spriteram_2;
295      source = m_buffered_spriteram_2;
298296
299   k007121_sprites_draw(k007121, bitmap, cliprect, machine.gfx[bank], machine.colortable, source, base_color, 40, 0, (UINT32)-1);
297   k007121_sprites_draw(k007121, bitmap, cliprect, machine().gfx[bank], machine().colortable, source, base_color, 40, 0, (UINT32)-1);
300298}
301299
302300UINT32 contra_state::screen_update_contra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20746r20747
314312   fg_finalclip &= cliprect;
315313   tx_finalclip &= cliprect;
316314
317   set_pens(machine());
315   set_pens();
318316
319317   m_fg_tilemap->set_scrollx(0, ctrl_1_0 - 40);
320318   m_fg_tilemap->set_scrolly(0, ctrl_1_2);
r20746r20747
323321
324322   m_bg_tilemap->draw(bitmap, bg_finalclip, 0 ,0);
325323   m_fg_tilemap->draw(bitmap, fg_finalclip, 0 ,0);
326   draw_sprites(machine(),bitmap,cliprect, 0);
327   draw_sprites(machine(),bitmap,cliprect, 1);
324   draw_sprites(bitmap,cliprect, 0);
325   draw_sprites(bitmap,cliprect, 1);
328326   m_tx_tilemap->draw(bitmap, tx_finalclip, 0 ,0);
329327   return 0;
330328}
trunk/src/mame/video/cyberbal.c
r20746r20747
201201 *
202202 *************************************/
203203
204INLINE void set_palette_entry(running_machine &machine, int entry, UINT16 value)
204inline void cyberbal_state::set_palette_entry(int entry, UINT16 value)
205205{
206206   int r, g, b;
207207
r20746r20747
209209   g = ((value >> 4) & 0x3e) | ((value >> 15) & 1);
210210   b = ((value << 1) & 0x3e) | ((value >> 15) & 1);
211211
212   palette_set_color_rgb(machine, entry, pal6bit(r), pal6bit(g), pal6bit(b));
212   palette_set_color_rgb(machine(), entry, pal6bit(r), pal6bit(g), pal6bit(b));
213213}
214214
215215
r20746r20747
223223WRITE16_HANDLER(cyberbal_state::paletteram_0_w)
224224{
225225   COMBINE_DATA(&m_paletteram_0[offset]);
226   set_palette_entry(machine(), offset, m_paletteram_0[offset]);
226   set_palette_entry(offset, m_paletteram_0[offset]);
227227}
228228
229229READ16_HANDLER(cyberbal_state::paletteram_0_r)
r20746r20747
235235WRITE16_HANDLER(cyberbal_state::paletteram_1_w)
236236{
237237   COMBINE_DATA(&m_paletteram_1[offset]);
238   set_palette_entry(machine(), offset + 0x800, m_paletteram_1[offset]);
238   set_palette_entry(offset + 0x800, m_paletteram_1[offset]);
239239}
240240
241241READ16_HANDLER(cyberbal_state::paletteram_1_r)
trunk/src/mame/video/cop01.c
r20746r20747
161161
162162***************************************************************************/
163163
164static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
164void cop01_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
165165{
166   cop01_state *state = machine.driver_data<cop01_state>();
167166   int offs, code, attr, sx, sy, flipx, flipy, color;
168167
169   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
168   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
170169   {
171      code = state->m_spriteram[offs + 1];
172      attr = state->m_spriteram[offs + 2];
170      code = m_spriteram[offs + 1];
171      attr = m_spriteram[offs + 2];
173172      /* xxxx---- color
174173       * ----xx-- flipy,flipx
175174       * -------x msbx
r20746r20747
178177      flipx = attr & 0x04;
179178      flipy = attr & 0x08;
180179
181      sx = (state->m_spriteram[offs + 3] - 0x80) + 256 * (attr & 0x01);
182      sy = 240 - state->m_spriteram[offs];
180      sx = (m_spriteram[offs + 3] - 0x80) + 256 * (attr & 0x01);
181      sy = 240 - m_spriteram[offs];
183182
184      if (state->flip_screen())
183      if (flip_screen())
185184      {
186185         sx = 240 - sx;
187186         sy = 240 - sy;
r20746r20747
190189      }
191190
192191      if (code & 0x80)
193         code += (state->m_vreg[0] & 0x30) << 3;
192         code += (m_vreg[0] & 0x30) << 3;
194193
195      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
194      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
196195         code,
197196         color,
198197         flipx,flipy,
r20746r20747
207206   m_bg_tilemap->set_scrolly(0, m_vreg[3]);
208207
209208   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
210   draw_sprites(machine(), bitmap, cliprect);
209   draw_sprites(bitmap, cliprect);
211210   m_bg_tilemap->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
212211   m_fg_tilemap->draw(bitmap, cliprect, 0, 0 );
213212   return 0;
trunk/src/mame/video/combatsc.c
r20746r20747
9090}
9191
9292
93static void set_pens( running_machine &machine )
93void combatsc_state::set_pens(  )
9494{
95   combatsc_state *state = machine.driver_data<combatsc_state>();
9695   int i;
9796
9897   for (i = 0x00; i < 0x100; i += 2)
9998   {
100      UINT16 data = state->m_paletteram[i] | (state->m_paletteram[i | 1] << 8);
99      UINT16 data = m_paletteram[i] | (m_paletteram[i | 1] << 8);
101100
102101      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
103102
104      colortable_palette_set_color(machine.colortable, i >> 1, color);
103      colortable_palette_set_color(machine().colortable, i >> 1, color);
105104   }
106105}
107106
r20746r20747
380379
381380***************************************************************************/
382381
383static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit, UINT32 pri_mask )
382void combatsc_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit, UINT32 pri_mask )
384383{
385   combatsc_state *state = machine.driver_data<combatsc_state>();
386   device_t *k007121 = circuit ? state->m_k007121_2 : state->m_k007121_1;
387   address_space &space = machine.driver_data()->generic_space();
384   device_t *k007121 = circuit ? m_k007121_2 : m_k007121_1;
385   address_space &space = machine().driver_data()->generic_space();
388386   int base_color = (circuit * 4) * 16 + (k007121_ctrlram_r(k007121, space, 6) & 0x10) * 2;
389387
390   k007121_sprites_draw(k007121, bitmap, cliprect, machine.gfx[circuit], machine.colortable, source, base_color, 0, 0, pri_mask);
388   k007121_sprites_draw(k007121, bitmap, cliprect, machine().gfx[circuit], machine().colortable, source, base_color, 0, 0, pri_mask);
391389}
392390
393391
r20746r20747
395393{
396394   int i;
397395
398   set_pens(machine());
396   set_pens();
399397
400398   address_space &space = machine().driver_data()->generic_space();
401399   if (k007121_ctrlram_r(m_k007121_1, space, 1) & 0x02)
r20746r20747
435433      m_bg_tilemap[0]->draw(bitmap, cliprect, 1, 2);
436434
437435      /* we use the priority buffer so sprites are drawn front to back */
438      draw_sprites(machine(), bitmap, cliprect, m_spriteram[1], 1, 0x0f00);
439      draw_sprites(machine(), bitmap, cliprect, m_spriteram[0], 0, 0x4444);
436      draw_sprites(bitmap, cliprect, m_spriteram[1], 1, 0x0f00);
437      draw_sprites(bitmap, cliprect, m_spriteram[0], 0, 0x4444);
440438   }
441439   else
442440   {
r20746r20747
446444      m_bg_tilemap[1]->draw(bitmap, cliprect, 0, 8);
447445
448446      /* we use the priority buffer so sprites are drawn front to back */
449      draw_sprites(machine(), bitmap, cliprect, m_spriteram[1], 1, 0x0f00);
450      draw_sprites(machine(), bitmap, cliprect, m_spriteram[0], 0, 0x4444);
447      draw_sprites(bitmap, cliprect, m_spriteram[1], 1, 0x0f00);
448      draw_sprites(bitmap, cliprect, m_spriteram[0], 0, 0x4444);
451449   }
452450
453451   if (k007121_ctrlram_r(m_k007121_1, space, 1) & 0x08)
r20746r20747
503501
504502***************************************************************************/
505503
506static void bootleg_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit )
504void combatsc_state::bootleg_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT8 *source, int circuit )
507505{
508   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
509   gfx_element *gfx = machine.gfx[circuit + 2];
506   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
507   gfx_element *gfx = machine().gfx[circuit + 2];
510508
511509   int limit = circuit ? (space.read_byte(0xc2) * 256 + space.read_byte(0xc3)) : (space.read_byte(0xc0) * 256 + space.read_byte(0xc1));
512510   const UINT8 *finish;
r20746r20747
536534         color = (circuit * 4) * 16 + (color >> 4);
537535
538536         /*  hacks to select alternate palettes */
539//          if(state->m_vreg == 0x40 && (attributes & 0x40)) color += 1*16;
540//          if(state->m_vreg == 0x23 && (attributes & 0x02)) color += 1*16;
541//          if(state->m_vreg == 0x66 ) color += 2*16;
537//          if(m_vreg == 0x40 && (attributes & 0x40)) color += 1*16;
538//          if(m_vreg == 0x23 && (attributes & 0x02)) color += 1*16;
539//          if(m_vreg == 0x66 ) color += 2*16;
542540
543541         drawgfx_transpen(   bitmap, cliprect, gfx,
544542                     number, color,
r20746r20747
553551{
554552   int i;
555553
556   set_pens(machine());
554   set_pens();
557555
558556   for (i = 0; i < 32; i++)
559557   {
r20746r20747
566564   if (m_priority == 0)
567565   {
568566      m_bg_tilemap[1]->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
569      bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[0], 0);
567      bootleg_draw_sprites(bitmap,cliprect, m_page[0], 0);
570568      m_bg_tilemap[0]->draw(bitmap, cliprect, 0 ,0);
571      bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[1], 1);
569      bootleg_draw_sprites(bitmap,cliprect, m_page[1], 1);
572570   }
573571   else
574572   {
575573      m_bg_tilemap[0]->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
576      bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[0], 0);
574      bootleg_draw_sprites(bitmap,cliprect, m_page[0], 0);
577575      m_bg_tilemap[1]->draw(bitmap, cliprect, 0, 0);
578      bootleg_draw_sprites(machine(), bitmap,cliprect, m_page[1], 1);
576      bootleg_draw_sprites(bitmap,cliprect, m_page[1], 1);
579577   }
580578
581579   m_textlayer->draw(bitmap, cliprect, 0, 0);
trunk/src/mame/video/cosmic.c
r20746r20747
248248}
249249
250250
251static void draw_bitmap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
251void cosmic_state::draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect )
252252{
253   cosmic_state *state = machine.driver_data<cosmic_state>();
254253   offs_t offs;
255254
256   for (offs = 0; offs < state->m_videoram.bytes(); offs++)
255   for (offs = 0; offs < m_videoram.bytes(); offs++)
257256   {
258257      int i;
259      UINT8 data = state->m_videoram[offs];
258      UINT8 data = m_videoram[offs];
260259
261260      UINT8 x = offs << 3;
262261      UINT8 y = offs >> 5;
263262
264      pen_t pen = state->m_map_color(machine, x, y);
263      pen_t pen = m_map_color(machine(), x, y);
265264
266265      for (i = 0; i < 8; i++)
267266      {
268267         if (data & 0x80)
269268         {
270            if (state->flip_screen())
269            if (flip_screen())
271270               bitmap.pix16(255-y, 255-x) = pen;
272271            else
273272               bitmap.pix16(y, x) = pen;
r20746r20747
280279}
281280
282281
283static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int extra_sprites )
282void cosmic_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int extra_sprites )
284283{
285   cosmic_state *state = machine.driver_data<cosmic_state>();
286284   int offs;
287285
288   for (offs = state->m_spriteram.bytes() - 4;offs >= 0;offs -= 4)
286   for (offs = m_spriteram.bytes() - 4;offs >= 0;offs -= 4)
289287   {
290      if (state->m_spriteram[offs] != 0)
288      if (m_spriteram[offs] != 0)
291289      {
292290         int code, color;
293291
294         code  = ~state->m_spriteram[offs] & 0x3f;
295         color = ~state->m_spriteram[offs + 3] & color_mask;
292         code  = ~m_spriteram[offs] & 0x3f;
293         color = ~m_spriteram[offs + 3] & color_mask;
296294
297295         if (extra_sprites)
298            code |= (state->m_spriteram[offs + 3] & 0x08) << 3;
296            code |= (m_spriteram[offs + 3] & 0x08) << 3;
299297
300         if (state->m_spriteram[offs] & 0x80)
298         if (m_spriteram[offs] & 0x80)
301299            /* 16x16 sprite */
302            drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
300            drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
303301                  code, color,
304                  0, ~state->m_spriteram[offs] & 0x40,
305                  256-state->m_spriteram[offs + 2],state->m_spriteram[offs + 1],0);
302                  0, ~m_spriteram[offs] & 0x40,
303                  256-m_spriteram[offs + 2],m_spriteram[offs + 1],0);
306304         else
307305            /* 32x32 sprite */
308            drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
306            drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
309307                  code >> 2, color,
310                  0, ~state->m_spriteram[offs] & 0x40,
311                  256-state->m_spriteram[offs + 2],state->m_spriteram[offs + 1],0);
308                  0, ~m_spriteram[offs] & 0x40,
309                  256-m_spriteram[offs + 2],m_spriteram[offs + 1],0);
312310      }
313311   }
314312}
315313
316314
317static void cosmica_draw_starfield( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
315void cosmic_state::cosmica_draw_starfield( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
318316{
319   cosmic_state *state = screen.machine().driver_data<cosmic_state>();
320317   UINT8 y = 0;
321318   UINT8 map = 0;
322   UINT8 *PROM = state->memregion("user2")->base();
319   UINT8 *PROM = memregion("user2")->base();
323320
324321   while (1)
325322   {
r20746r20747
333330         UINT8 x1;
334331         int hc, hb_;
335332
336         if (state->flip_screen())
333         if (flip_screen())
337334            x1 = x - screen.frame_number();
338335         else
339336            x1 = x + screen.frame_number();
r20746r20747
364361}
365362
366363
367static void devzone_draw_grid( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
364void cosmic_state::devzone_draw_grid( bitmap_ind16 &bitmap, const rectangle &cliprect )
368365{
369   cosmic_state *state = machine.driver_data<cosmic_state>();
370366   UINT8 y;
371   UINT8 *horz_PROM = state->memregion("user2")->base();
372   UINT8 *vert_PROM = state->memregion("user3")->base();
367   UINT8 *horz_PROM = memregion("user2")->base();
368   UINT8 *vert_PROM = memregion("user3")->base();
373369   offs_t horz_addr = 0;
374370
375371   UINT8 count = 0;
r20746r20747
405401            if (!(vert_data & horz_data & 0x80))    /* NAND gate */
406402            {
407403               /* blue */
408               if (state->flip_screen())
404               if (flip_screen())
409405                  bitmap.pix16(255-y, 255-x) = 4;
410406               else
411407                  bitmap.pix16(y, x) = 4;
r20746r20747
423419}
424420
425421
426static void nomnlnd_draw_background( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
422void cosmic_state::nomnlnd_draw_background( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
427423{
428   cosmic_state *state = screen.machine().driver_data<cosmic_state>();
429424   UINT8 y = 0;
430425   UINT8 water = screen.frame_number();
431   UINT8 *PROM = state->memregion("user2")->base();
426   UINT8 *PROM = memregion("user2")->base();
432427
433428   /* all positioning is via logic gates:
434429
r20746r20747
491486            if ((!hd_) & hc_ & (!hb_))
492487            {
493488               offs_t offs = ((x >> 3) & 0x03) | ((y & 0x1f) << 2) |
494                           (state->flip_screen() ? 0x80 : 0);
489                           (flip_screen() ? 0x80 : 0);
495490
496491               UINT8 plane1 = PROM[offs         ] << (x & 0x07);
497492               UINT8 plane2 = PROM[offs | 0x0400] << (x & 0x07);
r20746r20747
525520
526521         if (color != 0)
527522         {
528            if (state->flip_screen())
523            if (flip_screen())
529524               bitmap.pix16(255-y, 255-x) = color;
530525            else
531526               bitmap.pix16(y, x) = color;
r20746r20747
549544UINT32 cosmic_state::screen_update_cosmicg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
550545{
551546   bitmap.fill(0, cliprect);
552   draw_bitmap(machine(), bitmap, cliprect);
547   draw_bitmap(bitmap, cliprect);
553548   return 0;
554549}
555550
r20746r20747
557552UINT32 cosmic_state::screen_update_panic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
558553{
559554   bitmap.fill(0, cliprect);
560   draw_bitmap(machine(), bitmap, cliprect);
561   draw_sprites(machine(), bitmap, cliprect, 0x07, 1);
555   draw_bitmap(bitmap, cliprect);
556   draw_sprites(bitmap, cliprect, 0x07, 1);
562557   return 0;
563558}
564559
r20746r20747
567562{
568563   bitmap.fill(0, cliprect);
569564   cosmica_draw_starfield(screen, bitmap, cliprect);
570   draw_bitmap(machine(), bitmap, cliprect);
571   draw_sprites(machine(), bitmap, cliprect, 0x0f, 0);
565   draw_bitmap(bitmap, cliprect);
566   draw_sprites(bitmap, cliprect, 0x0f, 0);
572567   return 0;
573568}
574569
r20746r20747
576571UINT32 cosmic_state::screen_update_magspot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
577572{
578573   bitmap.fill(0, cliprect);
579   draw_bitmap(machine(), bitmap, cliprect);
580   draw_sprites(machine(), bitmap, cliprect, 0x07, 0);
574   draw_bitmap(bitmap, cliprect);
575   draw_sprites(bitmap, cliprect, 0x07, 0);
581576   return 0;
582577}
583578
r20746r20747
587582   bitmap.fill(0, cliprect);
588583
589584   if (m_background_enable)
590      devzone_draw_grid(machine(), bitmap, cliprect);
585      devzone_draw_grid(bitmap, cliprect);
591586
592   draw_bitmap(machine(), bitmap, cliprect);
593   draw_sprites(machine(), bitmap, cliprect, 0x07, 0);
587   draw_bitmap(bitmap, cliprect);
588   draw_sprites(bitmap, cliprect, 0x07, 0);
594589   return 0;
595590}
596591
r20746r20747
601596      have the highest priority */
602597
603598   bitmap.fill(0, cliprect);
604   draw_bitmap(machine(), bitmap, cliprect);
605   draw_sprites(machine(), bitmap, cliprect, 0x07, 0);
599   draw_bitmap(bitmap, cliprect);
600   draw_sprites(bitmap, cliprect, 0x07, 0);
606601
607602   if (m_background_enable)
608603      nomnlnd_draw_background(screen, bitmap, cliprect);
trunk/src/mame/video/carpolo.c
r20746r20747
186186}
187187
188188
189static void remap_sprite_code(running_machine &machine, int bank, int code, int *remapped_code, int *flipy)
189void carpolo_state::remap_sprite_code(int bank, int code, int *remapped_code, int *flipy)
190190{
191   UINT8* PROM = machine.root_device().memregion("user1")->base();
191   UINT8* PROM = machine().root_device().memregion("user1")->base();
192192
193193   code = (bank << 4) | code;
194194   *remapped_code = PROM[code] & 0x0f;
r20746r20747
196196}
197197
198198
199static void draw_sprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect,
199void carpolo_state::draw_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect,
200200                  UINT8 x, UINT8 y, int bank, int code, int col)
201201{
202202   int remapped_code, flipy;
203203
204   remap_sprite_code(machine, bank, code, &remapped_code, &flipy);
204   remap_sprite_code(bank, code, &remapped_code, &flipy);
205205
206206   x = 240 - x;
207207   y = 240 - y;
208208
209   drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
209   drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
210210         remapped_code, col,
211211         0, flipy,
212212         x, y,0);
213213
214214   /* draw with wrap around */
215   drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
215   drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
216216         remapped_code, col,
217217         0, flipy,
218218         (INT16)x - 256, y,0);
r20746r20747
230230   bitmap.plot_box(0,TOP_BORDER,RIGHT_BORDER+1,BOTTOM_BORDER-TOP_BORDER+1,FIELD_PEN);
231231
232232   /* car 1 */
233   draw_sprite(machine(), bitmap, cliprect,
233   draw_sprite(bitmap, cliprect,
234234            m_spriteram[0x00], m_spriteram[0x01],
235235            0, m_spriteram[0x0c] & 0x0f, CAR1_COLOR);
236236
r20746r20747
241241   bitmap.plot_box(RIGHT_BORDER,TOP_BORDER,1,BOTTOM_BORDER-TOP_BORDER+1,LINE_PEN);
242242
243243   /* car 4 */
244   draw_sprite(machine(), bitmap, cliprect,
244   draw_sprite(bitmap, cliprect,
245245            m_spriteram[0x06], m_spriteram[0x07],
246246            0, m_spriteram[0x0d] >> 4, CAR4_COLOR);
247247
248248   /* car 3 */
249   draw_sprite(machine(), bitmap, cliprect,
249   draw_sprite(bitmap, cliprect,
250250            m_spriteram[0x04], m_spriteram[0x05],
251251            0, m_spriteram[0x0d] & 0x0f, CAR3_COLOR);
252252
253253   /* car 2 */
254   draw_sprite(machine(), bitmap, cliprect,
254   draw_sprite(bitmap, cliprect,
255255            m_spriteram[0x02], m_spriteram[0x03],
256256            0, m_spriteram[0x0c] >> 4, CAR2_COLOR);
257257
258258   /* ball */
259   draw_sprite(machine(), bitmap, cliprect,
259   draw_sprite(bitmap, cliprect,
260260            m_spriteram[0x08], m_spriteram[0x09],
261261            1, m_spriteram[0x0e] & 0x0f, BALL_COLOR);
262262
r20746r20747
281281      popmessage("WIDE!\n");
282282
283283   if (m_spriteram[0x0f] & 0x01)
284      draw_sprite(machine(), bitmap, cliprect,
284      draw_sprite(bitmap, cliprect,
285285               m_spriteram[0x0a], m_spriteram[0x0b],
286286               1, m_spriteram[0x0e] >> 4, SPECIAL_CHAR_COLOR);
287287
r20746r20747
311311 *
312312 *************************************/
313313
314static void normalize_coordinates(int *x1, int *y1, int *x2, int *y2)
314void carpolo_state::normalize_coordinates(int *x1, int *y1, int *x2, int *y2)
315315{
316316   if (*x1 < *x2)
317317   {
r20746r20747
337337}
338338
339339
340static int check_sprite_sprite_collision(running_machine &machine,
341                                 int x1, int y1, int code1, int flipy1,
340int carpolo_state::check_sprite_sprite_collision(int x1, int y1, int code1, int flipy1,
342341                                 int x2, int y2, int code2, int flipy2,
343342                                 int *col_x, int *col_y)
344343{
345   carpolo_state *state = machine.driver_data<carpolo_state>();
346344   int collided = 0;
347345
348346   x1 = 240 - x1;
r20746r20747
357355
358356      normalize_coordinates(&x1, &y1, &x2, &y2);
359357
360      state->m_sprite_sprite_collision_bitmap1->fill(0);
361      state->m_sprite_sprite_collision_bitmap2->fill(0);
358      m_sprite_sprite_collision_bitmap1->fill(0);
359      m_sprite_sprite_collision_bitmap2->fill(0);
362360
363      drawgfx_opaque(*state->m_sprite_sprite_collision_bitmap1,state->m_sprite_sprite_collision_bitmap1->cliprect(),machine.gfx[0],
361      drawgfx_opaque(*m_sprite_sprite_collision_bitmap1,m_sprite_sprite_collision_bitmap1->cliprect(),machine().gfx[0],
364362            code1,0,
365363            0,flipy1,
366364            x1,y1);
367365
368      drawgfx_opaque(*state->m_sprite_sprite_collision_bitmap2,state->m_sprite_sprite_collision_bitmap2->cliprect(),machine.gfx[0],
366      drawgfx_opaque(*m_sprite_sprite_collision_bitmap2,m_sprite_sprite_collision_bitmap2->cliprect(),machine().gfx[0],
369367            code2,0,
370368            0,flipy2,
371369            x2,y2);
372370
373371      for (x = x1; x < x1 + SPRITE_WIDTH; x++)
374372         for (y = y1; y < y1 + SPRITE_HEIGHT; y++)
375            if ((state->m_sprite_sprite_collision_bitmap1->pix16(y, x) == 1) &&
376               (state->m_sprite_sprite_collision_bitmap2->pix16(y, x) == 1))
373            if ((m_sprite_sprite_collision_bitmap1->pix16(y, x) == 1) &&
374               (m_sprite_sprite_collision_bitmap2->pix16(y, x) == 1))
377375            {
378376               *col_x = (x1 + x) & 0x0f;
379377               *col_y = (y1 + y) & 0x0f;
r20746r20747
390388
391389/* returns 1 for collision with goal post,
392390   2 for collision with scoring area */
393static int check_sprite_left_goal_collision(running_machine &machine, int x1, int y1, int code1, int flipy1, int goalpost_only)
391int carpolo_state::check_sprite_left_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only)
394392{
395   carpolo_state *state = machine.driver_data<carpolo_state>();
396393   int collided = 0;
397394
398395   x1 = 240 - x1;
r20746r20747
411408
412409      normalize_coordinates(&x1, &y1, &x2, &y2);
413410
414      state->m_sprite_goal_collision_bitmap1->fill(0);
415      state->m_sprite_goal_collision_bitmap2->fill(0);
411      m_sprite_goal_collision_bitmap1->fill(0);
412      m_sprite_goal_collision_bitmap2->fill(0);
416413
417      drawgfx_opaque(*state->m_sprite_goal_collision_bitmap1,state->m_sprite_goal_collision_bitmap1->cliprect(),machine.gfx[0],
414      drawgfx_opaque(*m_sprite_goal_collision_bitmap1,m_sprite_goal_collision_bitmap1->cliprect(),machine().gfx[0],
418415            code1,0,
419416            0,flipy1,
420417            x1,y1);
421418
422      drawgfxzoom_transpen(*state->m_sprite_goal_collision_bitmap2,state->m_sprite_goal_collision_bitmap2->cliprect(),machine.gfx[1],
419      drawgfxzoom_transpen(*m_sprite_goal_collision_bitmap2,m_sprite_goal_collision_bitmap2->cliprect(),machine().gfx[1],
423420               0,0,
424421               0,0,
425422               x2,y2,
r20746r20747
427424
428425      for (x = x1; x < x1 + SPRITE_WIDTH; x++)
429426         for (y = y1; y < y1 + SPRITE_HEIGHT; y++)
430            if (state->m_sprite_goal_collision_bitmap1->pix16(y, x) == 1)
427            if (m_sprite_goal_collision_bitmap1->pix16(y, x) == 1)
431428            {
432               pen_t pix = state->m_sprite_goal_collision_bitmap2->pix16(y, x);
429               pen_t pix = m_sprite_goal_collision_bitmap2->pix16(y, x);
433430
434431               if (pix == LEFT_GOAL_PEN)
435432               {
r20746r20747
449446}
450447
451448
452static int check_sprite_right_goal_collision(running_machine &machine, int x1, int y1, int code1, int flipy1, int goalpost_only)
449int carpolo_state::check_sprite_right_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only)
453450{
454   carpolo_state *state = machine.driver_data<carpolo_state>();
455451   int collided = 0;
456452
457453   x1 = 240 - x1;
r20746r20747
469465
470466      normalize_coordinates(&x1, &y1, &x2, &y2);
471467
472      state->m_sprite_goal_collision_bitmap1->fill(0);
473      state->m_sprite_goal_collision_bitmap2->fill(0);
468      m_sprite_goal_collision_bitmap1->fill(0);
469      m_sprite_goal_collision_bitmap2->fill(0);
474470
475      drawgfx_opaque(*state->m_sprite_goal_collision_bitmap1,state->m_sprite_goal_collision_bitmap1->cliprect(),machine.gfx[0],
471      drawgfx_opaque(*m_sprite_goal_collision_bitmap1,m_sprite_goal_collision_bitmap1->cliprect(),machine().gfx[0],
476472            code1,0,
477473            0,flipy1,
478474            x1,y1);
479475
480      drawgfxzoom_transpen(*state->m_sprite_goal_collision_bitmap2,state->m_sprite_goal_collision_bitmap2->cliprect(),machine.gfx[1],
476      drawgfxzoom_transpen(*m_sprite_goal_collision_bitmap2,m_sprite_goal_collision_bitmap2->cliprect(),machine().gfx[1],
481477               0,1,
482478               1,0,
483479               x2,y2,
r20746r20747
485481
486482      for (x = x1; x < x1 + SPRITE_WIDTH; x++)
487483         for (y = y1; y < y1 + SPRITE_HEIGHT; y++)
488            if (state->m_sprite_goal_collision_bitmap1->pix16(y, x) == 1)
484            if (m_sprite_goal_collision_bitmap1->pix16(y, x) == 1)
489485            {
490               pen_t pix = state->m_sprite_goal_collision_bitmap2->pix16(y, x);
486               pen_t pix = m_sprite_goal_collision_bitmap2->pix16(y, x);
491487
492488               if (pix == RIGHT_GOAL_PEN)
493489               {
r20746r20747
509505
510506/* returns 1 for collision with vertical border,
511507   2 for collision with horizontal border */
512static int check_sprite_border_collision(running_machine &machine, UINT8 x1, UINT8 y1, int code1, int flipy1)
508int carpolo_state::check_sprite_border_collision(UINT8 x1, UINT8 y1, int code1, int flipy1)
513509{
514   carpolo_state *state = machine.driver_data<carpolo_state>();
515510   UINT8 x,y;
516511   int collided = 0;
517512
518513   x1 = 240 - x1;
519514   y1 = 240 - y1;
520515
521   drawgfx_opaque(*state->m_sprite_border_collision_bitmap,state->m_sprite_border_collision_bitmap->cliprect(),machine.gfx[0],
516   drawgfx_opaque(*m_sprite_border_collision_bitmap,m_sprite_border_collision_bitmap->cliprect(),machine().gfx[0],
522517         code1,0,
523518         0,flipy1,
524519         0,0);
525520
526521   for (x = 0; x < SPRITE_WIDTH; x++)
527522      for (y = 0; y < SPRITE_HEIGHT; y++)
528         if (state->m_sprite_border_collision_bitmap->pix16(y, x) == 1)
523         if (m_sprite_border_collision_bitmap->pix16(y, x) == 1)
529524         {
530525            if (((UINT8)(x1 + x) == LEFT_BORDER) ||
531526               ((UINT8)(x1 + x) == RIGHT_BORDER))
r20746r20747
562557
563558      car1_x = m_spriteram[0x00];
564559      car1_y = m_spriteram[0x01];
565      remap_sprite_code(machine(), 0, m_spriteram[0x0c] & 0x0f, &car1_code, &car1_flipy);
560      remap_sprite_code(0, m_spriteram[0x0c] & 0x0f, &car1_code, &car1_flipy);
566561
567562      car2_x = m_spriteram[0x02];
568563      car2_y = m_spriteram[0x03];
569      remap_sprite_code(machine(), 0, m_spriteram[0x0c] >> 4,   &car2_code, &car2_flipy);
564      remap_sprite_code(0, m_spriteram[0x0c] >> 4,   &car2_code, &car2_flipy);
570565
571566      car3_x = m_spriteram[0x04];
572567      car3_y = m_spriteram[0x05];
573      remap_sprite_code(machine(), 0, m_spriteram[0x0d] & 0x0f, &car3_code, &car3_flipy);
568      remap_sprite_code(0, m_spriteram[0x0d] & 0x0f, &car3_code, &car3_flipy);
574569
575570      car4_x = m_spriteram[0x06];
576571      car4_y = m_spriteram[0x07];
577      remap_sprite_code(machine(), 0, m_spriteram[0x0d] >> 4,   &car4_code, &car4_flipy);
572      remap_sprite_code(0, m_spriteram[0x0d] >> 4,   &car4_code, &car4_flipy);
578573
579574      ball_x = m_spriteram[0x08];
580575      ball_y = m_spriteram[0x09];
581      remap_sprite_code(machine(), 1, m_spriteram[0x0e] & 0x0f, &ball_code, &ball_flipy);
576      remap_sprite_code(1, m_spriteram[0x0e] & 0x0f, &ball_code, &ball_flipy);
582577
583578
584579      /* cars 1 and 2 */
585      if (check_sprite_sprite_collision(machine(),
586                                 car1_x, car1_y, car1_code, car1_flipy,
580      if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy,
587581                                 car2_x, car2_y, car2_code, car2_flipy,
588582                                 &col_x, &col_y))
589         carpolo_generate_car_car_interrupt(machine(), 0, 1);
583         carpolo_generate_car_car_interrupt(0, 1);
590584
591585      /* cars 1 and 3 */
592      else if (check_sprite_sprite_collision(machine(),
593                                    car1_x, car1_y, car1_code, car1_flipy,
586      else if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy,
594587                                    car3_x, car3_y, car3_code, car3_flipy,
595588                                    &col_x, &col_y))
596         carpolo_generate_car_car_interrupt(machine(), 0, 2);
589         carpolo_generate_car_car_interrupt(0, 2);
597590
598591      /* cars 1 and 4 */
599      else if (check_sprite_sprite_collision(machine(),
600                                    car1_x, car1_y, car1_code, car1_flipy,
592      else if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy,
601593                                    car4_x, car4_y, car4_code, car4_flipy,
602594                                    &col_x, &col_y))
603         carpolo_generate_car_car_interrupt(machine(), 0, 3);
595         carpolo_generate_car_car_interrupt(0, 3);
604596
605597      /* cars 2 and 3 */
606      else if (check_sprite_sprite_collision(machine(),
607                                    car2_x, car2_y, car2_code, car2_flipy,
598      else if (check_sprite_sprite_collision(car2_x, car2_y, car2_code, car2_flipy,
608599                                    car3_x, car3_y, car3_code, car3_flipy,
609600                                    &col_x, &col_y))
610         carpolo_generate_car_car_interrupt(machine(), 1, 2);
601         carpolo_generate_car_car_interrupt(1, 2);
611602
612603      /* cars 2 and 4 */
613      else if (check_sprite_sprite_collision(machine(),
614                                    car2_x, car2_y, car2_code, car2_flipy,
604      else if (check_sprite_sprite_collision(car2_x, car2_y, car2_code, car2_flipy,
615605                                    car4_x, car4_y, car4_code, car4_flipy,
616606                                    &col_x, &col_y))
617         carpolo_generate_car_car_interrupt(machine(), 1, 3);
607         carpolo_generate_car_car_interrupt(1, 3);
618608
619609      /* cars 3 and 4 */
620      else if (check_sprite_sprite_collision(machine(),
621                                    car3_x, car3_y, car3_code, car3_flipy,
610      else if (check_sprite_sprite_collision(car3_x, car3_y, car3_code, car3_flipy,
622611                                    car4_x, car4_y, car4_code, car4_flipy,
623612                                    &col_x, &col_y))
624         carpolo_generate_car_car_interrupt(machine(), 2, 3);
613         carpolo_generate_car_car_interrupt(2, 3);
625614
626615
627616
628617      /* check car-ball collision */
629      if (check_sprite_sprite_collision(machine(),
630                                 car1_x, car1_y, car1_code, car1_flipy,
618      if (check_sprite_sprite_collision(car1_x, car1_y, car1_code, car1_flipy,
631619                                 ball_x, ball_y, ball_code, ball_flipy,
632620                                 &col_x, &col_y))
633         carpolo_generate_car_ball_interrupt(machine(), 0, col_x, col_y);
621         carpolo_generate_car_ball_interrupt(0, col_x, col_y);
634622
635      else if (check_sprite_sprite_collision(machine(),
636                                    car2_x, car2_y, car2_code, car2_flipy,
623      else if (check_sprite_sprite_collision(car2_x, car2_y, car2_code, car2_flipy,
637624                                    ball_x, ball_y, ball_code, ball_flipy,
638625                                    &col_x, &col_y))
639         carpolo_generate_car_ball_interrupt(machine(), 1, col_x, col_y);
626         carpolo_generate_car_ball_interrupt(1, col_x, col_y);
640627
641      else if (check_sprite_sprite_collision(machine(),
642                                    car3_x, car3_y, car3_code, car3_flipy,
628      else if (check_sprite_sprite_collision(car3_x, car3_y, car3_code, car3_flipy,
643629                                    ball_x, ball_y, ball_code, ball_flipy,
644630                                    &col_x, &col_y))
645         carpolo_generate_car_ball_interrupt(machine(), 2, col_x, col_y);
631         carpolo_generate_car_ball_interrupt(2, col_x, col_y);
646632
647      else if (check_sprite_sprite_collision(machine(),
648                                    car4_x, car4_y, car4_code, car4_flipy,
633      else if (check_sprite_sprite_collision(car4_x, car4_y, car4_code, car4_flipy,
649634                                    ball_x, ball_y, ball_code, ball_flipy,
650635                                    &col_x, &col_y))
651         carpolo_generate_car_ball_interrupt(machine(), 3, col_x, col_y);
636         carpolo_generate_car_ball_interrupt(3, col_x, col_y);
652637
653638
654639      /* check car-goal collision */
655      if (check_sprite_left_goal_collision(machine(), car1_x, car1_y, car1_code, car1_flipy, 1))
656         carpolo_generate_car_goal_interrupt(machine(), 0, 0);
640      if (check_sprite_left_goal_collision(car1_x, car1_y, car1_code, car1_flipy, 1))
641         carpolo_generate_car_goal_interrupt(0, 0);
657642
658      else if (check_sprite_right_goal_collision(machine(), car1_x, car1_y, car1_code, car1_flipy, 1))
659         carpolo_generate_car_goal_interrupt(machine(), 0, 1);
643      else if (check_sprite_right_goal_collision(car1_x, car1_y, car1_code, car1_flipy, 1))
644         carpolo_generate_car_goal_interrupt(0, 1);
660645
661      else if (check_sprite_left_goal_collision(machine(), car2_x, car2_y, car2_code, car2_flipy, 1))
662         carpolo_generate_car_goal_interrupt(machine(), 1, 0);
646      else if (check_sprite_left_goal_collision(car2_x, car2_y, car2_code, car2_flipy, 1))
647         carpolo_generate_car_goal_interrupt(1, 0);
663648
664      else if (check_sprite_right_goal_collision(machine(), car2_x, car2_y, car2_code, car2_flipy, 1))
665         carpolo_generate_car_goal_interrupt(machine(), 1, 1);
649      else if (check_sprite_right_goal_collision(car2_x, car2_y, car2_code, car2_flipy, 1))
650         carpolo_generate_car_goal_interrupt(1, 1);
666651
667      else if (check_sprite_left_goal_collision(machine(), car3_x, car3_y, car3_code, car3_flipy, 1))
668         carpolo_generate_car_goal_interrupt(machine(), 2, 0);
652      else if (check_sprite_left_goal_collision(car3_x, car3_y, car3_code, car3_flipy, 1))
653         carpolo_generate_car_goal_interrupt(2, 0);
669654
670      else if (check_sprite_right_goal_collision(machine(), car3_x, car3_y, car3_code, car3_flipy, 1))
671         carpolo_generate_car_goal_interrupt(machine(), 2, 1);
655      else if (check_sprite_right_goal_collision(car3_x, car3_y, car3_code, car3_flipy, 1))
656         carpolo_generate_car_goal_interrupt(2, 1);
672657
673      else if (check_sprite_left_goal_collision(machine(), car4_x, car4_y, car4_code, car4_flipy, 1))
674         carpolo_generate_car_goal_interrupt(machine(), 3, 0);
658      else if (check_sprite_left_goal_collision(car4_x, car4_y, car4_code, car4_flipy, 1))
659         carpolo_generate_car_goal_interrupt(3, 0);
675660
676      else if (check_sprite_right_goal_collision(machine(), car4_x, car4_y, car4_code, car4_flipy, 1))
677         carpolo_generate_car_goal_interrupt(machine(), 3, 1);
661      else if (check_sprite_right_goal_collision(car4_x, car4_y, car4_code, car4_flipy, 1))
662         carpolo_generate_car_goal_interrupt(3, 1);
678663
679664
680665      /* check ball collision with static screen elements */
681666      {
682667         int col;
683668
684         col = check_sprite_left_goal_collision(machine(), ball_x, ball_y, ball_code, ball_flipy, 0);
669         col = check_sprite_left_goal_collision(ball_x, ball_y, ball_code, ball_flipy, 0);
685670
686         if (col == 1)  carpolo_generate_ball_screen_interrupt(machine(), 0x05);
687         if (col == 2)  carpolo_generate_ball_screen_interrupt(machine(), 0x03);
671         if (col == 1)  carpolo_generate_ball_screen_interrupt(0x05);
672         if (col == 2)  carpolo_generate_ball_screen_interrupt(0x03);
688673
689674
690         col = check_sprite_right_goal_collision(machine(), ball_x, ball_y, ball_code, ball_flipy, 0);
675         col = check_sprite_right_goal_collision(ball_x, ball_y, ball_code, ball_flipy, 0);
691676
692         if (col == 1)  carpolo_generate_ball_screen_interrupt(machine(), 0x05 | 0x08);
693         if (col == 2)  carpolo_generate_ball_screen_interrupt(machine(), 0x03 | 0x08);
677         if (col == 1)  carpolo_generate_ball_screen_interrupt(0x05 | 0x08);
678         if (col == 2)  carpolo_generate_ball_screen_interrupt(0x03 | 0x08);
694679
695680
696         if (check_sprite_border_collision(machine(), ball_x, ball_y, ball_code, ball_flipy))
697            carpolo_generate_ball_screen_interrupt(machine(), 0x06);
681         if (check_sprite_border_collision(ball_x, ball_y, ball_code, ball_flipy))
682            carpolo_generate_ball_screen_interrupt(0x06);
698683      }
699684
700685
r20746r20747
702687      {
703688         int col;
704689
705         col = check_sprite_border_collision(machine(), car1_x, car1_y, car1_code, car1_flipy);
690         col = check_sprite_border_collision(car1_x, car1_y, car1_code, car1_flipy);
706691
707692         if (col)
708            carpolo_generate_car_border_interrupt(machine(), 0, (col == 2));
693            carpolo_generate_car_border_interrupt(0, (col == 2));
709694         else
710695         {
711            col = check_sprite_border_collision(machine(), car2_x, car2_y, car2_code, car2_flipy);
696            col = check_sprite_border_collision(car2_x, car2_y, car2_code, car2_flipy);
712697
713698            if (col)
714               carpolo_generate_car_border_interrupt(machine(), 1, (col == 2));
699               carpolo_generate_car_border_interrupt(1, (col == 2));
715700            else
716701            {
717               col = check_sprite_border_collision(machine(), car3_x, car3_y, car3_code, car3_flipy);
702               col = check_sprite_border_collision(car3_x, car3_y, car3_code, car3_flipy);
718703
719704               if (col)
720                  carpolo_generate_car_border_interrupt(machine(), 2, (col == 2));
705                  carpolo_generate_car_border_interrupt(2, (col == 2));
721706               else
722707               {
723                  col = check_sprite_border_collision(machine(), car4_x, car4_y, car4_code, car4_flipy);
708                  col = check_sprite_border_collision(car4_x, car4_y, car4_code, car4_flipy);
724709
725710                  if (col)
726                     carpolo_generate_car_border_interrupt(machine(), 3, (col == 2));
711                     carpolo_generate_car_border_interrupt(3, (col == 2));
727712               }
728713            }
729714         }
trunk/src/mame/video/champbas.c
r20746r20747
188188
189189
190190
191static void champbas_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
191void champbas_state::champbas_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
192192{
193   champbas_state *state = machine.driver_data<champbas_state>();
194193   int offs;
195   gfx_element* const gfx = machine.gfx[1];
194   gfx_element* const gfx = machine().gfx[1];
196195
197   for (offs = state->m_spriteram.bytes() - 2; offs >= 0; offs -= 2)
196   for (offs = m_spriteram.bytes() - 2; offs >= 0; offs -= 2)
198197   {
199      int code = (state->m_spriteram[offs] >> 2) | (state->m_gfx_bank << 6);
200      int color = (state->m_spriteram[offs + 1] & 0x1f) | (state->m_palette_bank << 6);
201      int flipx = ~state->m_spriteram[offs] & 0x01;
202      int flipy = ~state->m_spriteram[offs] & 0x02;
203      int sx = state->m_spriteram_2[offs + 1] - 16;
204      int sy = 255 - state->m_spriteram_2[offs];
198      int code = (m_spriteram[offs] >> 2) | (m_gfx_bank << 6);
199      int color = (m_spriteram[offs + 1] & 0x1f) | (m_palette_bank << 6);
200      int flipx = ~m_spriteram[offs] & 0x01;
201      int flipy = ~m_spriteram[offs] & 0x02;
202      int sx = m_spriteram_2[offs + 1] - 16;
203      int sy = 255 - m_spriteram_2[offs];
205204
206205      drawgfx_transmask(bitmap, cliprect,
207206            gfx,
208207            code, color,
209208            flipx, flipy,
210209            sx, sy,
211            colortable_get_transpen_mask(machine.colortable, gfx, color, 0));
210            colortable_get_transpen_mask(machine().colortable, gfx, color, 0));
212211
213212      // wraparound
214213      drawgfx_transmask(bitmap, cliprect,
r20746r20747
216215            code, color,
217216            flipx, flipy,
218217            sx + 256, sy,
219            colortable_get_transpen_mask(machine.colortable, gfx, color, 0));
218            colortable_get_transpen_mask(machine().colortable, gfx, color, 0));
220219   }
221220}
222221
223static void exctsccr_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
222void champbas_state::exctsccr_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
224223{
225   champbas_state *state = machine.driver_data<champbas_state>();
226224   int offs;
227225   UINT8 *obj1, *obj2;
228226
229   obj1 = state->m_bg_videoram;
230   obj2 = &(state->m_spriteram[0x20]);
227   obj1 = m_bg_videoram;
228   obj2 = &(m_spriteram[0x20]);
231229
232230   for (offs = 0x0e; offs >= 0; offs -= 2)
233231   {
r20746r20747
243241      bank = ((obj1[offs + 1] >> 4) & 1);
244242
245243      drawgfx_transpen(bitmap,cliprect,
246            machine.gfx[1],
244            machine().gfx[1],
247245            code + (bank << 6),
248246            color,
249247            flipx, flipy,
250248            sx,sy,0);
251249   }
252250
253   obj1 = state->m_spriteram_2;
254   obj2 = state->m_spriteram;
251   obj1 = m_spriteram_2;
252   obj2 = m_spriteram;
255253
256254   for (offs = 0x0e; offs >= 0; offs -= 2)
257255   {
r20746r20747
266264      color = (obj1[offs + 1]) & 0x0f;
267265
268266      drawgfx_transmask(bitmap,cliprect,
269            machine.gfx[2],
267            machine().gfx[2],
270268            code,
271269            color,
272270            flipx, flipy,
273271            sx,sy,
274            colortable_get_transpen_mask(machine.colortable, machine.gfx[2], color, 0x10));
272            colortable_get_transpen_mask(machine().colortable, machine().gfx[2], color, 0x10));
275273   }
276274}
277275
r20746r20747
280278UINT32 champbas_state::screen_update_champbas(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
281279{
282280   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
283   champbas_draw_sprites(machine(), bitmap, cliprect);
281   champbas_draw_sprites(bitmap, cliprect);
284282   return 0;
285283}
286284
287285UINT32 champbas_state::screen_update_exctsccr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
288286{
289287   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
290   exctsccr_draw_sprites(machine(), bitmap, cliprect);
288   exctsccr_draw_sprites(bitmap, cliprect);
291289   return 0;
292290}
trunk/src/mame/video/crshrace.c
r20746r20747
9595
9696***************************************************************************/
9797
98static void draw_bg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
98void crshrace_state::draw_bg( bitmap_ind16 &bitmap, const rectangle &cliprect )
9999{
100   crshrace_state *state = machine.driver_data<crshrace_state>();
101   state->m_tilemap2->draw(bitmap, cliprect, 0, 0);
100   m_tilemap2->draw(bitmap, cliprect, 0, 0);
102101}
103102
104103
105static void draw_fg(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
104void crshrace_state::draw_fg(bitmap_ind16 &bitmap, const rectangle &cliprect)
106105{
107   crshrace_state *state = machine.driver_data<crshrace_state>();
108   k053936_zoom_draw(state->m_k053936, bitmap, cliprect, state->m_tilemap1, 0, 0, 1);
106   k053936_zoom_draw(m_k053936, bitmap, cliprect, m_tilemap1, 0, 0, 1);
109107}
110108
111109
r20746r20747
125123   {
126124      case 0x00:  /* high score screen */
127125         m_spr->draw_sprites(m_spriteram->buffer(), 0x2000,  machine(), bitmap, cliprect);
128         draw_bg(machine(), bitmap, cliprect);
129         draw_fg(machine(), bitmap, cliprect);
126         draw_bg(bitmap, cliprect);
127         draw_fg(bitmap, cliprect);
130128         break;
131129      case 0x01:
132130      case 0x02:
133         draw_bg(machine(), bitmap, cliprect);
134         draw_fg(machine(), bitmap, cliprect);
131         draw_bg(bitmap, cliprect);
132         draw_fg(bitmap, cliprect);
135133         m_spr->draw_sprites(m_spriteram->buffer(), 0x2000,  machine(), bitmap, cliprect);
136134         break;
137135      default:
trunk/src/mame/video/cchasm.c
r20746r20747
2424   machine().device("maincpu")->execute().set_input_line(2, ASSERT_LINE);
2525}
2626
27static void cchasm_refresh (running_machine &machine)
27void cchasm_state::cchasm_refresh ()
2828{
29   cchasm_state *state = machine.driver_data<cchasm_state>();
3029
3130   int pc = 0;
3231   int done = 0;
r20746r20747
4140
4241   while (!done)
4342   {
44      data = state->m_ram[pc];
43      data = m_ram[pc];
4544      opcode = data >> 12;
4645      data &= 0xfff;
4746      if ((opcode > COLOR) && (data & 0x800))
r20746r20747
6665         break;
6766      case POSY:
6867         move = 1;
69         currenty = state->m_ycenter + (data << 16);
68         currenty = m_ycenter + (data << 16);
7069         break;
7170      case SCALEX:
7271         scalex = data << 5;
7372         break;
7473      case POSX:
7574         move = 1;
76         currentx = state->m_xcenter - (data << 16);
75         currentx = m_xcenter - (data << 16);
7776         break;
7877      case LENGTH:
7978         if (move)
8079         {
81            vector_add_point (machine, currentx, currenty, 0, 0);
80            vector_add_point (machine(), currentx, currenty, 0, 0);
8281            move = 0;
8382         }
8483
r20746r20747
8887         total_length += abs(data);
8988
9089         if (color)
91            vector_add_point (machine, currentx, currenty, color, 0xff);
90            vector_add_point (machine(), currentx, currenty, color, 0xff);
9291         else
9392            move = 1;
9493         break;
r20746r20747
9998      }
10099   }
101100   /* Refresh processor runs with 6 MHz */
102   machine.scheduler().timer_set (attotime::from_hz(6000000) * total_length, timer_expired_delegate(FUNC(cchasm_state::cchasm_refresh_end),state));
101   machine().scheduler().timer_set (attotime::from_hz(6000000) * total_length, timer_expired_delegate(FUNC(cchasm_state::cchasm_refresh_end),this));
103102}
104103
105104
r20746r20747
110109      switch (data >> 8)
111110      {
112111      case 0x37:
113         cchasm_refresh(machine());
112         cchasm_refresh();
114113         break;
115114      case 0xf7:
116115         machine().device("maincpu")->execute().set_input_line(2, CLEAR_LINE);
trunk/src/mame/video/clshroad.c
r20746r20747
280280
281281***************************************************************************/
282282
283static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
283void clshroad_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
284284{
285   clshroad_state *state = machine.driver_data<clshroad_state>();
286   UINT8 *spriteram = state->m_spriteram;
285   UINT8 *spriteram = m_spriteram;
287286   int i;
288287
289   for (i = 0; i < state->m_spriteram.bytes() ; i += 8)
288   for (i = 0; i < m_spriteram.bytes() ; i += 8)
290289   {
291290      int y       =    240 - spriteram[i+1];
292291      int code    =   (spriteram[i+3] & 0x3f) + (spriteram[i+2] << 6);
r20746r20747
297296      int flipy   =   0;
298297
299298      x -= 0x4a/2;
300      if (state->flip_screen())
299      if (flip_screen())
301300      {
302301         y = 240 - y;
303302         flipx = !flipx;
304303         flipy = !flipy;
305304      }
306305
307      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
306      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
308307            code,
309308            attr & 0x0f,
310309            flipx,flipy,
r20746r20747
332331
333332   m_tilemap_0a->draw(bitmap, cliprect, 0,0);  // Opaque
334333   m_tilemap_0b->draw(bitmap, cliprect, 0,0);
335   draw_sprites(machine(),bitmap,cliprect);
334   draw_sprites(bitmap,cliprect);
336335   m_tilemap_1->draw(bitmap, cliprect, 0,0);
337336   return 0;
338337}
trunk/src/mame/video/changela.c
r20746r20747
4040
4141***************************************************************************/
4242
43static void draw_obj0( running_machine &machine, bitmap_ind16 &bitmap, int sy )
43void changela_state::draw_obj0( bitmap_ind16 &bitmap, int sy )
4444{
45   changela_state *state = machine.driver_data<changela_state>();
4645   int sx, i;
4746
48   UINT8* ROM = state->memregion("user1")->base();
49   UINT8* RAM = state->m_spriteram;
47   UINT8* ROM = memregion("user1")->base();
48   UINT8* RAM = m_spriteram;
5049
5150   for (sx = 0; sx < 256; sx++)
5251   {
r20746r20747
103102
104103***************************************************************************/
105104
106static void draw_obj1( running_machine &machine, bitmap_ind16 &bitmap )
105void changela_state::draw_obj1( bitmap_ind16 &bitmap )
107106{
108   changela_state *state = machine.driver_data<changela_state>();
109107   int sx, sy;
110108
111   UINT8* ROM = state->memregion("gfx2")->base();
112   UINT8* RAM = state->m_videoram;
109   UINT8* ROM = memregion("gfx2")->base();
110   UINT8* RAM = m_videoram;
113111
114112   UINT8 reg[4] = { 0 }; /* 4x4-bit registers (U58, U59) */
115113
r20746r20747
168166
169167***************************************************************************/
170168
171static void draw_river( running_machine &machine, bitmap_ind16 &bitmap, int sy )
169void changela_state::draw_river( bitmap_ind16 &bitmap, int sy )
172170{
173   changela_state *state = machine.driver_data<changela_state>();
174171   int sx, i, j;
175172
176   UINT8* ROM = state->memregion("user2")->base();
177   UINT8* RAM = state->m_memory_devices + 0x800;
178   UINT8* TILE_ROM = state->memregion("gfx1")->base();
179   UINT8* TILE_RAM = state->m_memory_devices + 0x1000;
180   UINT8* PROM = state->memregion("proms")->base();
173   UINT8* ROM = memregion("user2")->base();
174   UINT8* RAM = m_memory_devices + 0x800;
175   UINT8* TILE_ROM = memregion("gfx1")->base();
176   UINT8* TILE_RAM = m_memory_devices + 0x1000;
177   UINT8* PROM = memregion("proms")->base();
181178
182179   int preload = ((sy < 32) ? 1 : 0);
183180
r20746r20747
194191   int carry = 0;
195192
196193   /* Update Counters */
197   if (sy == 30) state->m_v_count_river = state->m_horizon;
198   state->m_v_count_river = (state->m_v_count_river + 1) & 0xff;
194   if (sy == 30) m_v_count_river = m_horizon;
195   m_v_count_river = (m_v_count_river + 1) & 0xff;
199196
200197   /* ----- STATE MACHINE ----- */
201198   for (i = 0; i < 0x20; i++)
r20746r20747
219216      if (prev_state & 0x10)
220217         hosc = (math_train[8] << 4) | math_train[9];
221218
222      rom_addr = state->m_slopeROM_bank | ((state->m_v_count_river & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
219      rom_addr = m_slopeROM_bank | ((m_v_count_river & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
223220      ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01;
224221      ram_addr =  (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5);
225222      mux45 = rom_count & 0x01;
226      mux61 = state->m_v_count_river & 0x01;
223      mux61 = m_v_count_river & 0x01;
227224
228225      switch (curr_state)
229226      {
r20746r20747
270267      prev_state = curr_state;
271268   }
272269
273   if (!(state->m_v_count_river & 0x80))
270   if (!(m_v_count_river & 0x80))
274271   {
275272      int h_count = 0x80 | (hosc >> 1);
276273      int tile_v = ((math_train[3] & 0x0c) >> 2) | ((math_train[2] & 0x0f) << 2) | ((math_train[1] & 0x07) << 6);
r20746r20747
347344
348345***************************************************************************/
349346
350static void draw_tree( running_machine &machine, bitmap_ind16 &bitmap, int sy, int tree_num )
347void changela_state::draw_tree( bitmap_ind16 &bitmap, int sy, int tree_num )
351348{
352   changela_state *state = machine.driver_data<changela_state>();
353349   int sx, i, j;
354350
355351   /* State machine */
356   UINT8* ROM = state->memregion("user2")->base();
357   UINT8* RAM = state->m_memory_devices + 0x840 + 0x40 * tree_num;
358   UINT8* PROM = state->memregion("proms")->base();
352   UINT8* ROM = memregion("user2")->base();
353   UINT8* RAM = m_memory_devices + 0x840 + 0x40 * tree_num;
354   UINT8* PROM = memregion("proms")->base();
359355
360356   /* Tree Data */
361   UINT8* RAM2 = state->m_tree_ram + 0x20 * tree_num;
362   UINT8* TILE_ROM = (tree_num ? (state->memregion("user3")->base() + 0x1000) : (state->memregion("gfx1")->base() + 0x2000));
363   UINT8* TILE_RAM = (tree_num ? (state->memregion("user3")->base()) : (state->m_memory_devices + 0x1800));
357   UINT8* RAM2 = m_tree_ram + 0x20 * tree_num;
358   UINT8* TILE_ROM = (tree_num ? (memregion("user3")->base() + 0x1000) : (memregion("gfx1")->base() + 0x2000));
359   UINT8* TILE_RAM = (tree_num ? (memregion("user3")->base()) : (m_memory_devices + 0x1800));
364360
365361   int preload = ((sy < 32) ? 1 : 0);
366362
r20746r20747
384380   /* Update Counters */
385381   if (sy == 30)
386382   {
387      state->m_tree_on[tree_num] = 0;
383      m_tree_on[tree_num] = 0;
388384      if (tree_num == 0)
389         state->m_v_count_tree = state->m_horizon;
385         m_v_count_tree = m_horizon;
390386   }
391387   if (tree_num == 0)
392      state->m_v_count_tree = (state->m_v_count_tree + 1) & 0xff;
388      m_v_count_tree = (m_v_count_tree + 1) & 0xff;
393389
394390   /* ----- STATE MACHINE ----- */
395391   for (i = 0; i < 0x20; i++)
r20746r20747
416412      if (prev_state & 0x10)
417413         hosc = (math_train[8] << 4) | math_train[9];
418414
419      rom_addr = state->m_slopeROM_bank | ((state->m_v_count_tree & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
415      rom_addr = m_slopeROM_bank | ((m_v_count_tree & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
420416      ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01;
421417      ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5);
422418      ram2_addr = (ram_count << 1) | ((curr_state & 0x20) >> 5);
423419      mux45 = rom_count & 0x01;
424      mux61 = state->m_v_count_tree & 0x01;
420      mux61 = m_v_count_tree & 0x01;
425421
426422      switch(curr_state)
427423      {
r20746r20747
441437            break;
442438      }
443439
444      if (!state->m_tree_on[tree_num])
440      if (!m_tree_on[tree_num])
445441      {
446         int mux82 = (state->m_v_count_tree & 0x01) ^ 0x01;
442         int mux82 = (m_v_count_tree & 0x01) ^ 0x01;
447443
448444         switch(curr_state)
449445         {
r20746r20747
531527      ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2);
532528      rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6);
533529
534      if (!(state->m_v_count_tree & 0x80) && (state->m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
535         state->m_tree_on[tree_num] = 1;
530      if (!(m_v_count_tree & 0x80) && (m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
531         m_tree_on[tree_num] = 1;
536532
537      if (state->m_tree_on[tree_num])
533      if (m_tree_on[tree_num])
538534      {
539535         if (tile_h & 0x01)
540536            col = TILE_ROM[rom_addr] & 0x0f;
r20746r20747
571567      ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2);
572568      rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6);
573569
574      if (!(state->m_v_count_tree & 0x80) && (state->m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
575         state->m_tree_on[tree_num] = 1;
570      if (!(m_v_count_tree & 0x80) && (m_tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
571         m_tree_on[tree_num] = 1;
576572
577      if (state->m_tree_on[tree_num])
573      if (m_tree_on[tree_num])
578574      {
579575         if (tile_h & 0x01)
580576            col = TILE_ROM[rom_addr] & 0x0f;
r20746r20747
591587
592588   /* Tree on only stays high if a pixel that is not 0xf is encountered,
593589      because any non 0xf pixel sets U56 high */
594   if (all_ff) state->m_tree_on[tree_num] = 0;
590   if (all_ff) m_tree_on[tree_num] = 0;
595591}
596592
597593/*
r20746r20747
655651   m_tree0_bitmap.fill(0x00, rect);
656652   m_tree1_bitmap.fill(0x00, rect);
657653
658   draw_river(machine(), m_river_bitmap, sy);
659   draw_obj0(machine(), m_obj0_bitmap, sy);
660   draw_tree(machine(), m_tree0_bitmap, sy, 0);
661   draw_tree(machine(), m_tree1_bitmap, sy, 1);
654   draw_river(m_river_bitmap, sy);
655   draw_obj0(m_obj0_bitmap, sy);
656   draw_tree(m_tree0_bitmap, sy, 0);
657   draw_tree(m_tree1_bitmap, sy, 1);
662658
663659   /* Collision Detection */
664660   for (sx = 1; sx < 256; sx++)
r20746r20747
725721   copybitmap_trans(bitmap, m_obj0_bitmap,  0, 0, 0, 0, cliprect, 0);
726722   copybitmap_trans(bitmap, m_tree0_bitmap, 0, 0, 0, 0, cliprect, 0);
727723   copybitmap_trans(bitmap, m_tree1_bitmap, 0, 0, 0, 0, cliprect, 0);
728   draw_obj1(machine(), bitmap);
724   draw_obj1(bitmap);
729725
730726   return 0;
731727}
trunk/src/mame/video/ccastles.c
r20746r20747
115115 *
116116 *************************************/
117117
118INLINE void ccastles_write_vram( running_machine &machine, UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
118inline void ccastles_state::ccastles_write_vram( UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
119119{
120   ccastles_state *state = machine.driver_data<ccastles_state>();
121   UINT8 *dest = &state->m_videoram[addr & 0x7ffe];
120   UINT8 *dest = &m_videoram[addr & 0x7ffe];
122121   UINT8 promaddr = 0;
123122   UINT8 wpbits;
124123
r20746r20747
141140   promaddr |= (pixba << 0);
142141
143142   /* look up the PROM result */
144   wpbits = state->m_wpprom[promaddr];
143   wpbits = m_wpprom[promaddr];
145144
146145   /* write to the appropriate parts of VRAM depending on the result */
147146   if (!(wpbits & 1))
r20746r20747
162161 *
163162 *************************************/
164163
165INLINE void bitmode_autoinc( running_machine &machine )
164inline void ccastles_state::bitmode_autoinc(  )
166165{
167   ccastles_state *state = machine.driver_data<ccastles_state>();
168166
169167   /* auto increment in the x-direction if it's enabled */
170   if (!state->m_video_control[0]) /* /AX */
168   if (!m_video_control[0]) /* /AX */
171169   {
172      if (!state->m_video_control[2]) /* /XINC */
173         state->m_bitmode_addr[0]++;
170      if (!m_video_control[2]) /* /XINC */
171         m_bitmode_addr[0]++;
174172      else
175         state->m_bitmode_addr[0]--;
173         m_bitmode_addr[0]--;
176174   }
177175
178176   /* auto increment in the y-direction if it's enabled */
179   if (!state->m_video_control[1]) /* /AY */
177   if (!m_video_control[1]) /* /AY */
180178   {
181      if (!state->m_video_control[3]) /* /YINC */
182         state->m_bitmode_addr[1]++;
179      if (!m_video_control[3]) /* /YINC */
180         m_bitmode_addr[1]++;
183181      else
184         state->m_bitmode_addr[1]--;
182         m_bitmode_addr[1]--;
185183   }
186184}
187185
r20746r20747
196194WRITE8_MEMBER(ccastles_state::ccastles_videoram_w)
197195{
198196   /* direct writes to VRAM go through the write protect PROM as well */
199   ccastles_write_vram(machine(), offset, data, 0, 0);
197   ccastles_write_vram(offset, data, 0, 0);
200198}
201199
202200
r20746r20747
216214   UINT8 result = m_videoram[addr] << ((~m_bitmode_addr[0] & 1) * 4);
217215
218216   /* autoincrement because /BITMD was selected */
219   bitmode_autoinc(machine());
217   bitmode_autoinc();
220218
221219   /* the low 4 bits of the data lines are not driven so make them all 1's */
222220   return result | 0x0f;
r20746r20747
232230   data = (data & 0xf0) | (data >> 4);
233231
234232   /* write through the generic VRAM routine, passing the low 2 X bits as PIXB/PIXA */
235   ccastles_write_vram(machine(), addr, data, 1, m_bitmode_addr[0] & 3);
233   ccastles_write_vram(addr, data, 1, m_bitmode_addr[0] & 3);
236234
237235   /* autoincrement because /BITMD was selected */
238   bitmode_autoinc(machine());
236   bitmode_autoinc();
239237}
240238
241239
242240WRITE8_MEMBER(ccastles_state::ccastles_bitmode_addr_w)
243241{
244242   /* write through to video RAM and also to the addressing latches */
245   ccastles_write_vram(machine(), offset, data, 0, 0);
243   ccastles_write_vram(offset, data, 0, 0);
246244   m_bitmode_addr[offset] = data;
247245}
248246
trunk/src/mame/video/chaknpop.c
r20746r20747
173173  Screen refresh
174174***************************************************************************/
175175
176static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
176void chaknpop_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
177177{
178   chaknpop_state *state = machine.driver_data<chaknpop_state>();
179178   int offs;
180179
181180   /* Draw the sprites */
182   for (offs = 0; offs < state->m_spr_ram.bytes(); offs += 4)
181   for (offs = 0; offs < m_spr_ram.bytes(); offs += 4)
183182   {
184      int sx = state->m_spr_ram[offs + 3];
185      int sy = 256 - 15 - state->m_spr_ram[offs];
186      int flipx = state->m_spr_ram[offs+1] & 0x40;
187      int flipy = state->m_spr_ram[offs+1] & 0x80;
188      int color = (state->m_spr_ram[offs + 2] & 7);
189      int tile = (state->m_spr_ram[offs + 1] & 0x3f) | ((state->m_spr_ram[offs + 2] & 0x38) << 3);
183      int sx = m_spr_ram[offs + 3];
184      int sy = 256 - 15 - m_spr_ram[offs];
185      int flipx = m_spr_ram[offs+1] & 0x40;
186      int flipy = m_spr_ram[offs+1] & 0x80;
187      int color = (m_spr_ram[offs + 2] & 7);
188      int tile = (m_spr_ram[offs + 1] & 0x3f) | ((m_spr_ram[offs + 2] & 0x38) << 3);
190189
191      if (state->m_flip_x)
190      if (m_flip_x)
192191      {
193192         sx = 240 - sx;
194193         flipx = !flipx;
195194      }
196      if (state->m_flip_y)
195      if (m_flip_y)
197196      {
198197         sy = 242 - sy;
199198         flipy = !flipy;
200199      }
201200
202201      drawgfx_transpen(bitmap,cliprect,
203            machine.gfx[0],
202            machine().gfx[0],
204203            tile,
205204            color,
206205            flipx, flipy,
r20746r20747
208207   }
209208}
210209
211static void draw_bitmap( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
210void chaknpop_state::draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect )
212211{
213   chaknpop_state *state = machine.driver_data<chaknpop_state>();
214   int dx = state->m_flip_x ? -1 : 1;
212   int dx = m_flip_x ? -1 : 1;
215213   int offs, i;
216214
217215   for (offs = 0; offs < 0x2000; offs++)
r20746r20747
219217      int x = ((offs & 0x1f) << 3) + 7;
220218      int y = offs >> 5;
221219
222      if (!state->m_flip_x)
220      if (!m_flip_x)
223221         x = 255 - x;
224222
225      if (!state->m_flip_y)
223      if (!m_flip_y)
226224         y = 255 - y;
227225
228226      for (i = 0x80; i > 0; i >>= 1, x += dx)
229227      {
230228         pen_t color = 0;
231229
232         if (state->m_vram1[offs] & i)
230         if (m_vram1[offs] & i)
233231            color |= 0x200; // green lower cage
234         if (state->m_vram2[offs] & i)
232         if (m_vram2[offs] & i)
235233            color |= 0x080;
236         if (state->m_vram3[offs] & i)
234         if (m_vram3[offs] & i)
237235            color |= 0x100; // green upper cage
238         if (state->m_vram4[offs] & i)
236         if (m_vram4[offs] & i)
239237            color |= 0x040; // tx mask
240238
241239         if (color)
r20746r20747
251249UINT32 chaknpop_state::screen_update_chaknpop(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
252250{
253251   m_tx_tilemap->draw(bitmap, cliprect, 0, 0);
254   draw_sprites(machine(), bitmap, cliprect);
255   draw_bitmap(machine(), bitmap, cliprect);
252   draw_sprites(bitmap, cliprect);
253   draw_bitmap(bitmap, cliprect);
256254   return 0;
257255}
trunk/src/mame/video/citycon.c
r20746r20747
9999
100100
101101
102static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
102void citycon_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
103103{
104   citycon_state *state = machine.driver_data<citycon_state>();
105104   int offs;
106105
107   for (offs = state->m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
106   for (offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4)
108107   {
109108      int sx, sy, flipx;
110109
111      sx = state->m_spriteram[offs + 3];
112      sy = 239 - state->m_spriteram[offs];
113      flipx = ~state->m_spriteram[offs + 2] & 0x10;
114      if (state->flip_screen())
110      sx = m_spriteram[offs + 3];
111      sy = 239 - m_spriteram[offs];
112      flipx = ~m_spriteram[offs + 2] & 0x10;
113      if (flip_screen())
115114      {
116115         sx = 240 - sx;
117116         sy = 238 - sy;
118117         flipx = !flipx;
119118      }
120119
121      drawgfx_transpen(bitmap, cliprect, machine.gfx[state->m_spriteram[offs + 1] & 0x80 ? 2 : 1],
122            state->m_spriteram[offs + 1] & 0x7f,
123            state->m_spriteram[offs + 2] & 0x0f,
124            flipx,state->flip_screen(),
120      drawgfx_transpen(bitmap, cliprect, machine().gfx[m_spriteram[offs + 1] & 0x80 ? 2 : 1],
121            m_spriteram[offs + 1] & 0x7f,
122            m_spriteram[offs + 2] & 0x0f,
123            flipx,flip_screen(),
125124            sx, sy, 0);
126125   }
127126}
128127
129128
130INLINE void changecolor_RRRRGGGGBBBBxxxx( running_machine &machine, int color, int indx )
129inline void citycon_state::changecolor_RRRRGGGGBBBBxxxx( int color, int indx )
131130{
132   citycon_state *state = machine.driver_data<citycon_state>();
133   int data = state->m_generic_paletteram_8[2 * indx | 1] | (state->m_generic_paletteram_8[2 * indx] << 8);
134   palette_set_color_rgb(machine, color, pal4bit(data >> 12), pal4bit(data >> 8), pal4bit(data >> 4));
131   int data = m_generic_paletteram_8[2 * indx | 1] | (m_generic_paletteram_8[2 * indx] << 8);
132   palette_set_color_rgb(machine(), color, pal4bit(data >> 12), pal4bit(data >> 8), pal4bit(data >> 4));
135133}
136134
137135UINT32 citycon_state::screen_update_citycon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20746r20747
145143      int i;
146144
147145      for (i = 0; i < 4; i++)
148         changecolor_RRRRGGGGBBBBxxxx(machine(), 640 + 4 * offs + i, 512 + 4 * indx + i);
146         changecolor_RRRRGGGGBBBBxxxx(640 + 4 * offs + i, 512 + 4 * indx + i);
149147   }
150148
151149
r20746r20747
156154
157155   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
158156   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
159   draw_sprites(machine(), bitmap, cliprect);
157   draw_sprites(bitmap, cliprect);
160158   return 0;
161159}
trunk/src/mame/video/capbowl.c
r20746r20747
152152 *
153153 *************************************/
154154
155INLINE rgb_t pen_for_pixel( UINT8 *src, UINT8 pix )
155inline rgb_t capbowl_state::pen_for_pixel( UINT8 *src, UINT8 pix )
156156{
157157   return MAKE_RGB(pal4bit(src[(pix << 1) + 0] >> 0),
158158               pal4bit(src[(pix << 1) + 1] >> 4),
trunk/src/mame/video/cclimber.c
r20746r20747
1111#include "includes/cclimber.h"
1212
1313
14#define CCLIMBER_FLIP_X     (state->m_flip_screen[0] & 0x01)
15#define CCLIMBER_FLIP_Y     (state->m_flip_screen[1] & 0x01)
14#define CCLIMBER_FLIP_X     (m_flip_screen[0] & 0x01)
15#define CCLIMBER_FLIP_Y     (m_flip_screen[1] & 0x01)
1616#define CCLIMBER_BG_PEN     (0)
1717#define SWIMMER_SIDE_BG_PEN (0x120)
1818#define SWIMMER_BG_SPLIT    (0x18 * 8)
r20746r20747
300300
301301***************************************************************************/
302302
303static void swimmer_set_background_pen(running_machine &machine)
303void cclimber_state::swimmer_set_background_pen()
304304{
305   cclimber_state *state = machine.driver_data<cclimber_state>();
306305   int bit0, bit1, bit2;
307306   int r, g, b;
308307
309308   /* red component */
310309   bit0 = 0;
311   bit1 = (*state->m_swimmer_background_color >> 6) & 0x01;
312   bit2 = (*state->m_swimmer_background_color >> 7) & 0x01;
310   bit1 = (*m_swimmer_background_color >> 6) & 0x01;
311   bit2 = (*m_swimmer_background_color >> 7) & 0x01;
313312   r = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2;
314313
315314   /* green component */
316   bit0 = (*state->m_swimmer_background_color >> 3) & 0x01;
317   bit1 = (*state->m_swimmer_background_color >> 4) & 0x01;
318   bit2 = (*state->m_swimmer_background_color >> 5) & 0x01;
315   bit0 = (*m_swimmer_background_color >> 3) & 0x01;
316   bit1 = (*m_swimmer_background_color >> 4) & 0x01;
317   bit2 = (*m_swimmer_background_color >> 5) & 0x01;
319318   g = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2;
320319
321320   /* blue component */
322   bit0 = (*state->m_swimmer_background_color >> 0) & 0x01;
323   bit1 = (*state->m_swimmer_background_color >> 1) & 0x01;
324   bit2 = (*state->m_swimmer_background_color >> 2) & 0x01;
321   bit0 = (*m_swimmer_background_color >> 0) & 0x01;
322   bit1 = (*m_swimmer_background_color >> 1) & 0x01;
323   bit2 = (*m_swimmer_background_color >> 2) & 0x01;
325324   b = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2;
326325
327   palette_set_color(machine, CCLIMBER_BG_PEN, MAKE_RGB(r, g, b));
326   palette_set_color(machine(), CCLIMBER_BG_PEN, MAKE_RGB(r, g, b));
328327}
329328
330329
r20746r20747
480479}
481480
482481
483static void draw_playfield(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
482void cclimber_state::draw_playfield(bitmap_ind16 &bitmap, const rectangle &cliprect)
484483{
485   cclimber_state *state = machine.driver_data<cclimber_state>();
486484   int i;
487485
488   state->m_pf_tilemap->mark_all_dirty();
489   state->m_pf_tilemap->set_flip((CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
486   m_pf_tilemap->mark_all_dirty();
487   m_pf_tilemap->set_flip((CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
490488                           (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0));
491489   for (i = 0; i < 32; i++)
492      state->m_pf_tilemap->set_scrolly(i, state->m_column_scroll[i]);
490      m_pf_tilemap->set_scrolly(i, m_column_scroll[i]);
493491
494   state->m_pf_tilemap->draw(bitmap, cliprect, 0, 0);
492   m_pf_tilemap->draw(bitmap, cliprect, 0, 0);
495493}
496494
497495
498static void cclimber_draw_bigsprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
496void cclimber_state::cclimber_draw_bigsprite(bitmap_ind16 &bitmap, const rectangle &cliprect)
499497{
500   cclimber_state *state = machine.driver_data<cclimber_state>();
501   UINT8 x = state->m_bigsprite_control[3] - 8;
502   UINT8 y = state->m_bigsprite_control[2];
503   int bigsprite_flip_x = (state->m_bigsprite_control[1] & 0x10) >> 4;
504   int bigsprite_flip_y = (state->m_bigsprite_control[1] & 0x20) >> 5;
498   UINT8 x = m_bigsprite_control[3] - 8;
499   UINT8 y = m_bigsprite_control[2];
500   int bigsprite_flip_x = (m_bigsprite_control[1] & 0x10) >> 4;
501   int bigsprite_flip_y = (m_bigsprite_control[1] & 0x20) >> 5;
505502
506503   if (bigsprite_flip_x)
507504      x = 0x80 - x;
r20746r20747
509506   if (bigsprite_flip_y)
510507      y = 0x80 - y;
511508
512   state->m_bs_tilemap->mark_all_dirty();
509   m_bs_tilemap->mark_all_dirty();
513510
514   state->m_bs_tilemap->set_flip((bigsprite_flip_x ? TILEMAP_FLIPX : 0) |
511   m_bs_tilemap->set_flip((bigsprite_flip_x ? TILEMAP_FLIPX : 0) |
515512                           (CCLIMBER_FLIP_Y ^ bigsprite_flip_y ? TILEMAP_FLIPY : 0));
516513
517   state->m_bs_tilemap->set_scrollx(0, x);
518   state->m_bs_tilemap->set_scrolly(0, y);
514   m_bs_tilemap->set_scrollx(0, x);
515   m_bs_tilemap->set_scrolly(0, y);
519516
520   state->m_bs_tilemap->draw(bitmap, cliprect, 0, 0);
517   m_bs_tilemap->draw(bitmap, cliprect, 0, 0);
521518}
522519
523520
524static void toprollr_draw_bigsprite(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
521void cclimber_state::toprollr_draw_bigsprite(bitmap_ind16 &bitmap, const rectangle &cliprect)
525522{
526   cclimber_state *state = machine.driver_data<cclimber_state>();
527   UINT8 x = state->m_bigsprite_control[3] - 8;
528   UINT8 y = state->m_bigsprite_control[2];
523   UINT8 x = m_bigsprite_control[3] - 8;
524   UINT8 y = m_bigsprite_control[2];
529525
530   state->m_bs_tilemap->mark_all_dirty();
526   m_bs_tilemap->mark_all_dirty();
531527
532   state->m_bs_tilemap->set_flip(CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0);
528   m_bs_tilemap->set_flip(CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0);
533529
534   state->m_bs_tilemap->set_scrollx(0, x);
535   state->m_bs_tilemap->set_scrolly(0, y);
530   m_bs_tilemap->set_scrollx(0, x);
531   m_bs_tilemap->set_scrolly(0, y);
536532
537   state->m_bs_tilemap->draw(bitmap, cliprect, 0, 0);
533   m_bs_tilemap->draw(bitmap, cliprect, 0, 0);
538534}
539535
540536
541static void cclimber_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx)
537void cclimber_state::cclimber_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx)
542538{
543   cclimber_state *state = gfx->machine().driver_data<cclimber_state>();
544539   int offs;
545540
546541   /* draw the sprites -- note that it is important to draw them exactly in this
547542      order, to have the correct priorities. */
548543   for (offs = 0x1c; offs >= 0; offs -= 4)
549544   {
550      int x = state->m_spriteram[offs + 3] + 1;
545      int x = m_spriteram[offs + 3] + 1;
551546      /* x + 1 is evident in cclimber and ckong. It looks worse,
552547      but it has been confirmed on several PCBs. */
553548
554      int y = 240 - state->m_spriteram[offs + 2];
549      int y = 240 - m_spriteram[offs + 2];
555550
556      int code = ((state->m_spriteram[offs + 1] & 0x10) << 3) |
557               ((state->m_spriteram[offs + 1] & 0x20) << 1) |
558               ( state->m_spriteram[offs + 0] & 0x3f);
551      int code = ((m_spriteram[offs + 1] & 0x10) << 3) |
552               ((m_spriteram[offs + 1] & 0x20) << 1) |
553               ( m_spriteram[offs + 0] & 0x3f);
559554
560      int color = state->m_spriteram[offs + 1] & 0x0f;
555      int color = m_spriteram[offs + 1] & 0x0f;
561556
562      int flipx = state->m_spriteram[offs + 0] & 0x40;
563      int flipy = state->m_spriteram[offs + 0] & 0x80;
557      int flipx = m_spriteram[offs + 0] & 0x40;
558      int flipy = m_spriteram[offs + 0] & 0x80;
564559
565560      if (CCLIMBER_FLIP_X)
566561      {
r20746r20747
579574}
580575
581576
582static void toprollr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx)
577void cclimber_state::toprollr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx)
583578{
584   cclimber_state *state = gfx->machine().driver_data<cclimber_state>();
585579   int offs;
586580
587581   /* draw the sprites -- note that it is important to draw them exactly in this
588582      order, to have the correct priorities. */
589583   for (offs = 0x1c; offs >= 0; offs -= 4)
590584   {
591      int x = state->m_spriteram[offs + 3];
592      int y = 240 - state->m_spriteram[offs + 2];
585      int x = m_spriteram[offs + 3];
586      int y = 240 - m_spriteram[offs + 2];
593587
594      int code = ((state->m_spriteram[offs + 1] & 0x10) << 3) |
595               ((state->m_spriteram[offs + 1] & 0x20) << 1) |
596               ( state->m_spriteram[offs + 0] & 0x3f);
588      int code = ((m_spriteram[offs + 1] & 0x10) << 3) |
589               ((m_spriteram[offs + 1] & 0x20) << 1) |
590               ( m_spriteram[offs + 0] & 0x3f);
597591
598      int color = state->m_spriteram[offs + 1] & 0x0f;
592      int color = m_spriteram[offs + 1] & 0x0f;
599593
600      int flipx = state->m_spriteram[offs + 0] & 0x40;
601      int flipy = state->m_spriteram[offs + 0] & 0x80;
594      int flipx = m_spriteram[offs + 0] & 0x40;
595      int flipy = m_spriteram[offs + 0] & 0x80;
602596
603597      if (CCLIMBER_FLIP_X)
604598      {
r20746r20747
617611}
618612
619613
620static void swimmer_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx)
614void cclimber_state::swimmer_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx)
621615{
622   cclimber_state *state = gfx->machine().driver_data<cclimber_state>();
623616   int offs;
624617
625618   /* draw the sprites -- note that it is important to draw them exactly in this
626619      order, to have the correct priorities. */
627620   for (offs = 0x1c; offs >= 0; offs -= 4)
628621   {
629      int x = state->m_spriteram[offs + 3];
630      int y = 240 - state->m_spriteram[offs + 2];
622      int x = m_spriteram[offs + 3];
623      int y = 240 - m_spriteram[offs + 2];
631624
632      int code = ((state->m_spriteram[offs + 1] & 0x10) << 2) |
633               (state->m_spriteram[offs + 0] & 0x3f);
625      int code = ((m_spriteram[offs + 1] & 0x10) << 2) |
626               (m_spriteram[offs + 0] & 0x3f);
634627
635      int color = ((*state->m_swimmer_palettebank & 0x01) << 4) |
636               (state->m_spriteram[offs + 1] & 0x0f);
628      int color = ((*m_swimmer_palettebank & 0x01) << 4) |
629               (m_spriteram[offs + 1] & 0x0f);
637630
638      int flipx = state->m_spriteram[offs + 0] & 0x40;
639      int flipy = state->m_spriteram[offs + 0] & 0x80;
631      int flipx = m_spriteram[offs + 0] & 0x40;
632      int flipy = m_spriteram[offs + 0] & 0x80;
640633
641634      if (CCLIMBER_FLIP_X)
642635      {
r20746r20747
658651UINT32 cclimber_state::screen_update_cclimber(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
659652{
660653   bitmap.fill(CCLIMBER_BG_PEN, cliprect);
661   draw_playfield(machine(), bitmap, cliprect);
654   draw_playfield(bitmap, cliprect);
662655
663656   /* draw the "big sprite" under the regular sprites */
664657   if ((m_bigsprite_control[0] & 0x01))
665658   {
666      cclimber_draw_bigsprite(machine(), bitmap, cliprect);
659      cclimber_draw_bigsprite(bitmap, cliprect);
667660      cclimber_draw_sprites(bitmap, cliprect, machine().gfx[1]);
668661   }
669662
r20746r20747
671664   else
672665   {
673666      cclimber_draw_sprites(bitmap, cliprect, machine().gfx[1]);
674      cclimber_draw_bigsprite(machine(), bitmap, cliprect);
667      cclimber_draw_bigsprite(bitmap, cliprect);
675668   }
676669
677670   return 0;
r20746r20747
680673
681674UINT32 cclimber_state::screen_update_yamato(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
682675{
683   cclimber_state *state = machine().driver_data<cclimber_state>();
684676   int i;
685677   UINT8 *sky_rom = memregion("user1")->base() + 0x1200;
686678
r20746r20747
693685         bitmap.pix16(j, (i - 8) & 0xff) = pen;
694686   }
695687
696   draw_playfield(machine(), bitmap, cliprect);
688   draw_playfield(bitmap, cliprect);
697689
698690   /* draw the "big sprite" under the regular sprites */
699691   if ((m_bigsprite_control[0] & 0x01))
700692   {
701      cclimber_draw_bigsprite(machine(), bitmap, cliprect);
693      cclimber_draw_bigsprite(bitmap, cliprect);
702694      toprollr_draw_sprites(bitmap, cliprect, machine().gfx[1]);
703695   }
704696
r20746r20747
706698   else
707699   {
708700      toprollr_draw_sprites(bitmap, cliprect, machine().gfx[1]);
709      cclimber_draw_bigsprite(machine(), bitmap, cliprect);
701      cclimber_draw_bigsprite(bitmap, cliprect);
710702   }
711703
712704   return 0;
r20746r20747
715707
716708UINT32 cclimber_state::screen_update_swimmer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
717709{
718   cclimber_state *state = machine().driver_data<cclimber_state>();
719   swimmer_set_background_pen(machine());
710   swimmer_set_background_pen();
720711
721712   if (*m_swimmer_side_background_enabled & 0x01)
722713   {
r20746r20747
746737   else
747738      bitmap.fill(CCLIMBER_BG_PEN, cliprect);
748739
749   draw_playfield(machine(), bitmap, cliprect);
740   draw_playfield(bitmap, cliprect);
750741
751742   /* draw the "big sprite" under the regular sprites */
752743   if ((m_bigsprite_control[0] & 0x01))
753744   {
754      cclimber_draw_bigsprite(machine(), bitmap, cliprect);
745      cclimber_draw_bigsprite(bitmap, cliprect);
755746      swimmer_draw_sprites(bitmap, cliprect, machine().gfx[1]);
756747   }
757748
r20746r20747
759750   else
760751   {
761752      swimmer_draw_sprites(bitmap, cliprect, machine().gfx[1]);
762      cclimber_draw_bigsprite(machine(), bitmap, cliprect);
753      cclimber_draw_bigsprite(bitmap, cliprect);
763754   }
764755
765756   return 0;
r20746r20747
768759
769760UINT32 cclimber_state::screen_update_toprollr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
770761{
771   cclimber_state *state = machine().driver_data<cclimber_state>();
772762   rectangle scroll_area_clip = cliprect;
773763   scroll_area_clip.min_x = 4*8;
774764   scroll_area_clip.max_x = 29*8-1;
r20746r20747
785775   if ((m_bigsprite_control[1] & 0x20))
786776   {
787777      toprollr_draw_sprites(bitmap, scroll_area_clip, machine().gfx[1]);
788      toprollr_draw_bigsprite(machine(), bitmap, scroll_area_clip);
778      toprollr_draw_bigsprite(bitmap, scroll_area_clip);
789779   }
790780
791781   /* draw the "big sprite" under the regular sprites */
792782   else
793783   {
794      toprollr_draw_bigsprite(machine(), bitmap, scroll_area_clip);
784      toprollr_draw_bigsprite(bitmap, scroll_area_clip);
795785      toprollr_draw_sprites(bitmap, scroll_area_clip, machine().gfx[1]);
796786   }
797787
trunk/src/mame/video/cninja.c
r20746r20747
2323
2424
2525/* The bootleg sprites are in a different format! */
26static void cninjabl_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
26void cninja_state::cninjabl_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
2727{
28   cninja_state *state = machine.driver_data<cninja_state>();
29   UINT16 *buffered_spriteram = state->m_spriteram->buffer();
28   UINT16 *buffered_spriteram = m_spriteram->buffer();
3029   int offs;
3130   int endoffs;
3231
r20746r20747
6665      }
6766
6867      flash = y & 0x1000;
69      if (flash && (machine.primary_screen->frame_number() & 1))
68      if (flash && (machine().primary_screen->frame_number() & 1))
7069         continue;
7170
7271      colour = (x >> 9) & 0x1f;
r20746r20747
9594         inc = 1;
9695      }
9796
98      if (state->flip_screen())
97      if (flip_screen())
9998      {
10099         y = 240 - y;
101100         x = 240 - x;
r20746r20747
108107
109108      while (multi >= 0)
110109      {
111         pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3],
110         pdrawgfx_transpen(bitmap,cliprect,machine().gfx[3],
112111               sprite - multi * inc,
113112               colour,
114113               fx,fy,
115114               x,y + mult * multi,
116               machine.priority_bitmap,pri,0);
115               machine().priority_bitmap,pri,0);
117116
118117         multi--;
119118      }
r20746r20747
163162   deco16ic_tilemap_1_draw(m_deco_tilegen2, bitmap, cliprect, 0, 2);
164163   deco16ic_tilemap_2_draw(m_deco_tilegen1, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 2);
165164   deco16ic_tilemap_2_draw(m_deco_tilegen1, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 4);
166   cninjabl_draw_sprites(machine(), bitmap, cliprect);
165   cninjabl_draw_sprites(bitmap, cliprect);
167166   deco16ic_tilemap_1_draw(m_deco_tilegen1, bitmap, cliprect, 0, 0);
168167   return 0;
169168}
trunk/src/mame/video/canyon.c
r20746r20747
2929}
3030
3131
32static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
32void canyon_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
3333{
34   canyon_state *state = machine.driver_data<canyon_state>();
3534   int i;
3635
3736   for (i = 0; i < 2; i++)
3837   {
39      int x = state->m_videoram[0x3d0 + 2 * i + 0x1];
40      int y = state->m_videoram[0x3d0 + 2 * i + 0x8];
41      int c = state->m_videoram[0x3d0 + 2 * i + 0x9];
38      int x = m_videoram[0x3d0 + 2 * i + 0x1];
39      int y = m_videoram[0x3d0 + 2 * i + 0x8];
40      int c = m_videoram[0x3d0 + 2 * i + 0x9];
4241
4342      drawgfx_transpen(bitmap, cliprect,
44         machine.gfx[1],
43         machine().gfx[1],
4544         c >> 3,
4645         i,
4746         !(c & 0x80), 0,
r20746r20747
5150}
5251
5352
54static void draw_bombs( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
53void canyon_state::draw_bombs( bitmap_ind16 &bitmap, const rectangle &cliprect )
5554{
56   canyon_state *state = machine.driver_data<canyon_state>();
5755   int i;
5856
5957   for (i = 0; i < 2; i++)
6058   {
61      int sx = 254 - state->m_videoram[0x3d0 + 2 * i + 0x5];
62      int sy = 246 - state->m_videoram[0x3d0 + 2 * i + 0xc];
59      int sx = 254 - m_videoram[0x3d0 + 2 * i + 0x5];
60      int sy = 246 - m_videoram[0x3d0 + 2 * i + 0xc];
6361
6462      rectangle rect(sx, sx + 1, sy, sy + 1);
6563      rect &= cliprect;
r20746r20747
7371{
7472   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
7573
76   draw_sprites(machine(), bitmap, cliprect);
74   draw_sprites(bitmap, cliprect);
7775
78   draw_bombs(machine(), bitmap, cliprect);
76   draw_bombs(bitmap, cliprect);
7977
8078   /* watchdog is disabled during service mode */
8179   machine().watchdog_enable(!(machine().root_device().ioport("IN2")->read() & 0x10));
trunk/src/mame/video/cabal.c
r20746r20747
9696
9797********************************************************************/
9898
99static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
99void cabal_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
100100{
101   cabal_state *state = machine.driver_data<cabal_state>();
102101   int offs,data0,data1,data2;
103   UINT16 *spriteram16 = state->m_spriteram;
102   UINT16 *spriteram16 = m_spriteram;
104103
105   for( offs = state->m_spriteram.bytes()/2 - 4; offs >= 0; offs -= 4 )
104   for( offs = m_spriteram.bytes()/2 - 4; offs >= 0; offs -= 4 )
106105   {
107106      data0 = spriteram16[offs];
108107      data1 = spriteram16[offs+1];
r20746r20747
119118
120119         if ( sx>256 )   sx -= 512;
121120
122         if (state->flip_screen())
121         if (flip_screen())
123122         {
124123            sx = 240 - sx;
125124            sy = 240 - sy;
r20746r20747
127126            flipy = !flipy;
128127         }
129128
130         drawgfx_transpen( bitmap,cliprect,machine.gfx[2],
129         drawgfx_transpen( bitmap,cliprect,machine().gfx[2],
131130            tile_number,
132131            color,
133132            flipx,flipy,
r20746r20747
140139UINT32 cabal_state::screen_update_cabal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
141140{
142141   m_background_layer->draw(bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
143   draw_sprites(machine(),bitmap,cliprect);
142   draw_sprites(bitmap,cliprect);
144143   m_text_layer->draw(bitmap, cliprect, 0,0);
145144   return 0;
146145}
trunk/src/mame/video/circusc.c
r20746r20747
158158
159159***************************************************************************/
160160
161static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
161void circusc_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
162162{
163   circusc_state *state = machine.driver_data<circusc_state>();
164163   int offs;
165164   UINT8 *sr;
166165
167   if ((*state->m_spritebank & 0x01) != 0)
168      sr = state->m_spriteram;
166   if ((*m_spritebank & 0x01) != 0)
167      sr = m_spriteram;
169168   else
170      sr = state->m_spriteram_2;
169      sr = m_spriteram_2;
171170
172   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
171   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
173172   {
174173      int code = sr[offs + 0] + 8 * (sr[offs + 1] & 0x20);
175174      int color = sr[offs + 1] & 0x0f;
r20746r20747
178177      int flipx = sr[offs + 1] & 0x40;
179178      int flipy = sr[offs + 1] & 0x80;
180179
181      if (state->flip_screen())
180      if (flip_screen())
182181      {
183182         sx = 240 - sx;
184183         sy = 240 - sy;
r20746r20747
187186      }
188187
189188
190      drawgfx_transmask(bitmap,cliprect,machine.gfx[1],
189      drawgfx_transmask(bitmap,cliprect,machine().gfx[1],
191190            code, color,
192191            flipx,flipy,
193192            sx,sy,
194            colortable_get_transpen_mask(machine.colortable, machine.gfx[1], color, 0));
193            colortable_get_transpen_mask(machine().colortable, machine().gfx[1], color, 0));
195194   }
196195}
197196
r20746r20747
206205
207206   bitmap.fill(0, cliprect);
208207   m_bg_tilemap->draw(bitmap, cliprect, 1, 0);
209   draw_sprites(machine(), bitmap, cliprect);
208   draw_sprites(bitmap, cliprect);
210209   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
211210   return 0;
212211}
trunk/src/mame/video/crgolf.c
r20746r20747
4747 *
4848 *************************************/
4949
50static void get_pens( running_machine &machine, pen_t *pens )
50void crgolf_state::get_pens( pen_t *pens )
5151{
5252   offs_t offs;
53   const UINT8 *prom = machine.root_device().memregion("proms")->base();
53   const UINT8 *prom = machine().root_device().memregion("proms")->base();
5454
5555   for (offs = 0; offs < NUM_PENS; offs++)
5656   {
r20746r20747
113113   offs_t offs;
114114   pen_t pens[NUM_PENS];
115115
116   get_pens(machine(), pens);
116   get_pens(pens);
117117
118118   /* for each byte in the video RAM */
119119   for (offs = 0; offs < VIDEORAM_SIZE / 3; offs++)
trunk/src/mame/video/cbuster.c
r20746r20747
1212
1313/* maybe the game should just use generic palette handling, and have a darker palette by design... */
1414
15static void update_24bitcol( running_machine &machine, int offset )
15void cbuster_state::update_24bitcol( int offset )
1616{
17   cbuster_state *state = machine.driver_data<cbuster_state>();
1817   UINT8 r, g, b; /* The highest palette value seems to be 0x8e */
1918
20   r = (UINT8)((float)((state->m_generic_paletteram_16[offset]  >> 0) & 0xff) * 1.75);
21   g = (UINT8)((float)((state->m_generic_paletteram_16[offset]  >> 8) & 0xff) * 1.75);
22   b = (UINT8)((float)((state->m_generic_paletteram2_16[offset] >> 0) & 0xff) * 1.75);
19   r = (UINT8)((float)((m_generic_paletteram_16[offset]  >> 0) & 0xff) * 1.75);
20   g = (UINT8)((float)((m_generic_paletteram_16[offset]  >> 8) & 0xff) * 1.75);
21   b = (UINT8)((float)((m_generic_paletteram2_16[offset] >> 0) & 0xff) * 1.75);
2322
24   palette_set_color(machine, offset, MAKE_RGB(r, g, b));
23   palette_set_color(machine(), offset, MAKE_RGB(r, g, b));
2524}
2625
2726WRITE16_MEMBER(cbuster_state::twocrude_palette_24bit_rg_w)
2827{
2928   COMBINE_DATA(&m_generic_paletteram_16[offset]);
30   update_24bitcol(machine(), offset);
29   update_24bitcol(offset);
3130}
3231
3332WRITE16_MEMBER(cbuster_state::twocrude_palette_24bit_b_w)
3433{
3534   COMBINE_DATA(&m_generic_paletteram2_16[offset]);
36   update_24bitcol(machine(), offset);
35   update_24bitcol(offset);
3736}
3837
3938
trunk/src/mame/video/compgolf.c
r20746r20747
8686-----x-- -------- -------- -------- Flip X
8787-------- -------- -------- -------- Flip Y(used?)
8888*/
89static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
89void compgolf_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
9090{
91   compgolf_state *state = machine.driver_data<compgolf_state>();
9291   int offs, fx, fy, x, y, color, sprite;
9392
9493   for (offs = 0; offs < 0x60; offs += 4)
9594   {
96      sprite = state->m_spriteram[offs + 1] + (((state->m_spriteram[offs] & 0xc0) >> 6) * 0x100);
97      x = 240 - state->m_spriteram[offs + 3];
98      y = state->m_spriteram[offs + 2];
99      color = (state->m_spriteram[offs] & 8)>>3;
100      fx = state->m_spriteram[offs] & 4;
95      sprite = m_spriteram[offs + 1] + (((m_spriteram[offs] & 0xc0) >> 6) * 0x100);
96      x = 240 - m_spriteram[offs + 3];
97      y = m_spriteram[offs + 2];
98      color = (m_spriteram[offs] & 8)>>3;
99      fx = m_spriteram[offs] & 4;
101100      fy = 0; /* ? */
102101
103      drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
102      drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
104103            sprite,
105104            color,fx,fy,x,y,0);
106105
107106      /* Double Height */
108      if(state->m_spriteram[offs] & 0x10)
107      if(m_spriteram[offs] & 0x10)
109108      {
110         drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
109         drawgfx_transpen(bitmap,cliprect,machine().gfx[0],
111110            sprite + 1,
112111            color, fx, fy, x, y + 16, 0);
113112      }
r20746r20747
124123
125124   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
126125   m_text_tilemap->draw(bitmap, cliprect, 0, 0);
127   draw_sprites(machine(), bitmap, cliprect);
126   draw_sprites(bitmap, cliprect);
128127   return 0;
129128}
trunk/src/mame/video/galaxia.c
r20746r20747
7676   SET_TILE_INFO_MEMBER(0, code, color, 0);
7777}
7878
79static void init_common( running_machine &machine )
79void galaxia_state::init_common()
8080{
8181   assert((STAR_PEN & 7) == 0);
82   cvs_init_stars(machine);
82   cvs_init_stars();
8383}
8484
8585VIDEO_START_MEMBER(galaxia_state,galaxia)
8686{
87   init_common(machine());
87   init_common();
8888
8989   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(galaxia_state::get_galaxia_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
9090   m_bg_tilemap->set_transparent_pen(0);
r20746r20747
9494
9595VIDEO_START_MEMBER(galaxia_state,astrowar)
9696{
97   init_common(machine());
97   init_common();
9898
9999   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(galaxia_state::get_astrowar_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
100100   m_bg_tilemap->set_transparent_pen(0);
r20746r20747
116116   bitmap_ind16 &s2636_2_bitmap = s2636_update(machine().device("s2636_2"), cliprect);
117117
118118   bitmap.fill(0, cliprect);
119   cvs_update_stars(machine(), bitmap, cliprect, STAR_PEN, 1);
119   cvs_update_stars(bitmap, cliprect, STAR_PEN, 1);
120120   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
121121
122122   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
r20746r20747
180180   bitmap_ind16 &s2636_0_bitmap = s2636_update(machine().device("s2636_0"), cliprect);
181181
182182   bitmap.fill(0, cliprect);
183   cvs_update_stars(machine(), bitmap, cliprect, STAR_PEN, 1);
183   cvs_update_stars(bitmap, cliprect, STAR_PEN, 1);
184184   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
185185   copybitmap(m_temp_bitmap, bitmap, 0, 0, 0, 0, cliprect);
186186
trunk/src/mame/video/cbasebal.c
r20746r20747
130130
131131***************************************************************************/
132132
133static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
133void cbasebal_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
134134{
135   cbasebal_state *state = machine.driver_data<cbasebal_state>();
136   UINT8 *spriteram = state->m_spriteram;
135   UINT8 *spriteram = m_spriteram;
137136   int offs, sx, sy;
138137
139138   /* the last entry is not a sprite, we skip it otherwise spang shows a bubble */
140139   /* moving diagonally across the screen */
141   for (offs = state->m_spriteram.bytes() - 8; offs >= 0; offs -= 4)
140   for (offs = m_spriteram.bytes() - 8; offs >= 0; offs -= 4)
142141   {
143142      int code = spriteram[offs];
144143      int attr = spriteram[offs + 1];
r20746r20747
147146      sx = spriteram[offs + 3] + ((attr & 0x10) << 4);
148147      sy = ((spriteram[offs + 2] + 8) & 0xff) - 8;
149148      code += (attr & 0xe0) << 3;
150      code += state->m_spritebank * 0x800;
149      code += m_spritebank * 0x800;
151150
152      if (state->m_flipscreen)
151      if (m_flipscreen)
153152      {
154153         sx = 496 - sx;
155154         sy = 240 - sy;
156155         flipx = !flipx;
157156      }
158157
159      drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
158      drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
160159            code,
161160            color,
162            flipx,state->m_flipscreen,
161            flipx,m_flipscreen,
163162            sx,sy,15);
164163   }
165164}
r20746r20747
172171      bitmap.fill(768, cliprect);
173172
174173   if (m_obj_on)
175      draw_sprites(machine(), bitmap, cliprect);
174      draw_sprites(bitmap, cliprect);
176175
177176   if (m_text_on)
178177      m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
trunk/src/mame/video/crbaloon.c
r20746r20747
7676}
7777
7878
79UINT16 crbaloon_get_collision_address(running_machine &machine)
79UINT16 crbaloon_state::crbaloon_get_collision_address()
8080{
81   crbaloon_state *state = machine.driver_data<crbaloon_state>();
82   return state->m_collision_address_clear ? 0xffff : state->m_collision_address;
81   return m_collision_address_clear ? 0xffff : m_collision_address;
8382}
8483
8584
86void crbaloon_set_clear_collision_address(running_machine &machine, int _crbaloon_collision_address_clear)
85void crbaloon_state::crbaloon_set_clear_collision_address(int _crbaloon_collision_address_clear)
8786{
88   crbaloon_state *state = machine.driver_data<crbaloon_state>();
89   state->m_collision_address_clear = !_crbaloon_collision_address_clear; /* active LO */
87   m_collision_address_clear = !_crbaloon_collision_address_clear; /* active LO */
9088}
9189
9290
9391
94static void draw_sprite_and_check_collision(running_machine &machine, bitmap_ind16 &bitmap)
92void crbaloon_state::draw_sprite_and_check_collision(bitmap_ind16 &bitmap)
9593{
96   crbaloon_state *state = machine.driver_data<crbaloon_state>();
9794   int y;
98   UINT8 code = state->m_spriteram[0] & 0x0f;
99   UINT8 color = state->m_spriteram[0] >> 4;
100   UINT8 sy = state->m_spriteram[2] - 32;
95   UINT8 code = m_spriteram[0] & 0x0f;
96   UINT8 color = m_spriteram[0] >> 4;
97   UINT8 sy = m_spriteram[2] - 32;
10198
102   UINT8 *gfx = state->memregion("gfx2")->base() + (code << 7);
99   UINT8 *gfx = memregion("gfx2")->base() + (code << 7);
103100
104101
105   if (state->flip_screen())
102   if (flip_screen())
106103      sy += 32;
107104
108105   /* assume no collision */
109   state->m_collision_address = 0xffff;
106   m_collision_address = 0xffff;
110107
111108   for (y = 0x1f; y >= 0; y--)
112109   {
113110      int x;
114111      UINT8 data = 0;
115      UINT8 sx = state->m_spriteram[1];
112      UINT8 sx = m_spriteram[1];
116113
117114      for (x = 0x1f; x >= 0; x--)
118115      {
r20746r20747
130127            if (bitmap.pix16(sy, sx) & 0x01)
131128               /* compute the collision address -- the +1 is via observation
132129                  of the game code, probably wrong for cocktail mode */
133               state->m_collision_address = ((((sy ^ 0xff) >> 3) << 5) | ((sx ^ 0xff) >> 3)) + 1;
130               m_collision_address = ((((sy ^ 0xff) >> 3) << 5) | ((sx ^ 0xff) >> 3)) + 1;
134131
135132            bitmap.pix16(sy, sx) = (color << 1) | 1;
136133         }
r20746r20747
148145{
149146   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
150147
151   draw_sprite_and_check_collision(machine(), bitmap);
148   draw_sprite_and_check_collision(bitmap);
152149
153150   return 0;
154151}
trunk/src/mame/video/cischeat.c
r20746r20747
111111
112112***************************************************************************/
113113
114static void prepare_shadows(cischeat_state *state)
114void cischeat_state::prepare_shadows(cischeat_state *state)
115115{
116116   int i;
117117   for (i = 0;i < 16;i++)
118      state->m_drawmode_table[i] = DRAWMODE_SOURCE;
118      m_drawmode_table[i] = DRAWMODE_SOURCE;
119119
120   state->m_drawmode_table[ 0] = DRAWMODE_SHADOW;
121   state->m_drawmode_table[15] = DRAWMODE_NONE;
120   m_drawmode_table[ 0] = DRAWMODE_SHADOW;
121   m_drawmode_table[15] = DRAWMODE_NONE;
122122}
123123
124124/**************************************************************************
r20746r20747
129129#define TILES_PER_PAGE_Y (0x20)
130130#define TILES_PER_PAGE (TILES_PER_PAGE_X * TILES_PER_PAGE_Y)
131131
132INLINE void scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which)
132inline void cischeat_state::scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which)
133133{
134   cischeat_state *state = space.machine().driver_data<cischeat_state>();
135   COMBINE_DATA(&state->m_scrollram[which][offset]);
136   if (offset < 0x40000/2 && state->m_tmap[which])
134   COMBINE_DATA(&m_scrollram[which][offset]);
135   if (offset < 0x40000/2 && m_tmap[which])
137136   {
138      if (state->m_scroll_flag[which] & 0x10) /* tiles are 8x8 */
137      if (m_scroll_flag[which] & 0x10) /* tiles are 8x8 */
139138      {
140         state->m_tmap[which]->mark_tile_dirty(offset);
139         m_tmap[which]->mark_tile_dirty(offset);
141140      }
142141      else
143142      {
144         state->m_tmap[which]->mark_tile_dirty(offset*4 + 0);
145         state->m_tmap[which]->mark_tile_dirty(offset*4 + 1);
146         state->m_tmap[which]->mark_tile_dirty(offset*4 + 2);
147         state->m_tmap[which]->mark_tile_dirty(offset*4 + 3);
143         m_tmap[which]->mark_tile_dirty(offset*4 + 0);
144         m_tmap[which]->mark_tile_dirty(offset*4 + 1);
145         m_tmap[which]->mark_tile_dirty(offset*4 + 2);
146         m_tmap[which]->mark_tile_dirty(offset*4 + 3);
148147      }
149148   }
150149}
r20746r20747
181180   SET_TILE_INFO_MEMBER(tmap, (code & 0xfff) * 4 + (tile_index & 3), code >> (16 - m_bits_per_color_code), 0);
182181}
183182
184static void create_tilemaps(running_machine &machine)
183void cischeat_state::create_tilemaps()
185184{
186   cischeat_state *state = machine.driver_data<cischeat_state>();
187185   int layer, i;
188186
189187   for (layer = 0; layer < 3; layer++)
190188   {
191189      /* 16x16 tilemaps */
192      state->m_tilemap[layer][0][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state),
190      m_tilemap[layer][0][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this),
193191                           8,8, TILES_PER_PAGE_X * 16, TILES_PER_PAGE_Y * 2);
194      state->m_tilemap[layer][0][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state),
192      m_tilemap[layer][0][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this),
195193                           8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 4);
196      state->m_tilemap[layer][0][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state),
194      m_tilemap[layer][0][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this),
197195                           8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 8);
198      state->m_tilemap[layer][0][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),state),
196      m_tilemap[layer][0][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_16x16),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_16x16),this),
199197                           8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 16);
200198
201199      /* 8x8 tilemaps */
202      state->m_tilemap[layer][1][0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state),
200      m_tilemap[layer][1][0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this),
203201                           8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 1);
204      state->m_tilemap[layer][1][1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state),
202      m_tilemap[layer][1][1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this),
205203                           8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
206      state->m_tilemap[layer][1][2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state),
204      m_tilemap[layer][1][2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this),
207205                           8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
208      state->m_tilemap[layer][1][3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),state), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),state),
206      m_tilemap[layer][1][3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(cischeat_state::cischeat_get_scroll_tile_info_8x8),this), tilemap_mapper_delegate(FUNC(cischeat_state::cischeat_scan_8x8),this),
209207                           8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 4);
210208
211209      /* set user data and transparency */
212210      for (i = 0; i < 8; i++)
213211      {
214         state->m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer);
215         state->m_tilemap[layer][i/4][i%4]->set_transparent_pen(15);
212         m_tilemap[layer][i/4][i%4]->set_user_data((void *)(FPTR)layer);
213         m_tilemap[layer][i/4][i%4]->set_transparent_pen(15);
216214      }
217215   }
218216}
r20746r20747
234232
235233   m_spriteram = &m_ram[0x8000/2];
236234
237   create_tilemaps(machine());
235   create_tilemaps();
238236   m_tmap[0] = m_tilemap[0][0][0];
239237   m_tmap[1] = m_tilemap[1][0][0];
240238   m_tmap[2] = m_tilemap[2][0][0];
r20746r20747
700698/*  Draw the road in the given bitmap. The priority1 and priority2 parameters
701699    specify the range of lines to draw  */
702700
703static void cischeat_draw_road(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency)
701void cischeat_state::cischeat_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency)
704702{
705   cischeat_state *state = machine.driver_data<cischeat_state>();
706703   int curr_code,sx,sy;
707704   int min_priority, max_priority;
708705
709706   rectangle rect      =   cliprect;
710   gfx_element *gfx        =   machine.gfx[(road_num & 1)?5:4];
707   gfx_element *gfx        =   machine().gfx[(road_num & 1)?5:4];
711708
712   UINT16 *roadram         =   state->m_roadram[road_num & 1];
709   UINT16 *roadram         =   m_roadram[road_num & 1];
713710
714711   int min_y = rect.min_y;
715712   int max_y = rect.max_y;
r20746r20747
790787/*  Draw the road in the given bitmap. The priority1 and priority2 parameters
791788    specify the range of lines to draw  */
792789
793static void f1gpstar_draw_road(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency)
790void cischeat_state::f1gpstar_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency)
794791{
795   cischeat_state *state = machine.driver_data<cischeat_state>();
796792   int sx,sy;
797793   int xstart;
798794   int min_priority, max_priority;
799795
800796   rectangle rect      =   cliprect;
801   gfx_element *gfx        =   machine.gfx[(road_num & 1)?5:4];
797   gfx_element *gfx        =   machine().gfx[(road_num & 1)?5:4];
802798
803   UINT16 *roadram         =   state->m_roadram[road_num & 1];
799   UINT16 *roadram         =   m_roadram[road_num & 1];
804800
805801   int min_y = rect.min_y;
806802   int max_y = rect.max_y;
r20746r20747
906902    sprites whose priority nibble is between 0 and 15 and whose
907903    colour code's high bit is set.  */
908904
909static void cischeat_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2)
905void cischeat_state::cischeat_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2)
910906{
911   cischeat_state *state = machine.driver_data<cischeat_state>();
912907   int x, sx, flipx, xzoom, xscale, xdim, xnum, xstart, xend, xinc;
913908   int y, sy, flipy, yzoom, yscale, ydim, ynum, ystart, yend, yinc;
914909   int code, attr, color, size, shadow;
915910
916911   int min_priority, max_priority, high_sprites;
917912
918   UINT16      *source =   state->m_spriteram;
913   UINT16      *source =   m_spriteram;
919914   const UINT16    *finish =   source + 0x1000/2;
920915
921916
r20746r20747
952947
953948      /* dimension of a tile after zoom */
954949#ifdef MAME_DEBUG
955      if ( machine.input().code_pressed(KEYCODE_Z) && machine.input().code_pressed(KEYCODE_M) )
950      if ( machine().input().code_pressed(KEYCODE_Z) && machine().input().code_pressed(KEYCODE_M) )
956951      {
957952         xdim    =   16 << 16;
958953         ydim    =   16 << 16;
r20746r20747
983978         continue;
984979
985980#ifdef MAME_DEBUG
986if ( (state->m_debugsprites) && ( ((attr & 0x0300)>>8) != (state->m_debugsprites-1) ) ) { continue; };
981if ( (m_debugsprites) && ( ((attr & 0x0300)>>8) != (m_debugsprites-1) ) ) { continue; };
987982#endif
988983
989984      xscale = xdim / 16;
r20746r20747
1002997      if (flipy)  { ystart = ynum-1;  yend = -1;    yinc = -1; }
1003998      else        { ystart = 0;       yend = ynum;  yinc = +1; }
1004999
1005      state->m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
1000      m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
10061001
10071002      for (y = ystart; y != yend; y += yinc)
10081003      {
10091004         for (x = xstart; x != xend; x += xinc)
10101005         {
1011            drawgfxzoom_transtable(bitmap,cliprect,machine.gfx[3],
1006            drawgfxzoom_transtable(bitmap,cliprect,machine().gfx[3],
10121007                     code++,
10131008                     color,
10141009                     flipx,flipy,
10151010                     (sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000,
1016                     xscale, yscale, state->m_drawmode_table, machine.shadow_table);
1011                     xscale, yscale, m_drawmode_table, machine().shadow_table);
10171012         }
10181013      }
10191014#ifdef MAME_DEBUG
10201015#if 0
1021if (machine.input().code_pressed(KEYCODE_X))
1016if (machine().input().code_pressed(KEYCODE_X))
10221017{   /* Display some info on each sprite */
10231018   sprintf(buf, "%04x",attr);
10241019   ui_draw_text(buf, sx>>16, sy>>16);
r20746r20747
10621057
10631058***************************************************************************/
10641059
1065static void bigrun_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2)
1060void cischeat_state::bigrun_draw_sprites(bitmap_ind16 &bitmap , const rectangle &cliprect, int priority1, int priority2)
10661061{
1067   cischeat_state *state = machine.driver_data<cischeat_state>();
10681062   int x, sx, flipx, xzoom, xscale, xdim, xnum, xstart, xend, xinc;
10691063   int y, sy, flipy, yzoom, yscale, ydim, ynum, ystart, yend, yinc;
10701064   int code, attr, color, size, shadow;
10711065
10721066   int min_priority, max_priority, high_sprites;
10731067
1074   UINT16      *source =   state->m_spriteram;
1068   UINT16      *source =   m_spriteram;
10751069   const UINT16    *finish =   source + 0x1000/2;
10761070
10771071   /* Move the priority values in place */
r20746r20747
11091103
11101104      /* dimension of a tile after zoom */
11111105#ifdef MAME_DEBUG
1112      if ( machine.input().code_pressed(KEYCODE_Z) && machine.input().code_pressed(KEYCODE_M) )
1106      if ( machine().input().code_pressed(KEYCODE_Z) && machine().input().code_pressed(KEYCODE_M) )
11131107      {
11141108         xdim    =   16 << 16;
11151109         ydim    =   16 << 16;
r20746r20747
11381132         continue;
11391133
11401134#ifdef MAME_DEBUG
1141if ( (state->m_debugsprites) && ( ((attr & 0x0300)>>8) != (state->m_debugsprites-1) ) ) { continue; };
1135if ( (m_debugsprites) && ( ((attr & 0x0300)>>8) != (m_debugsprites-1) ) ) { continue; };
11421136#endif
11431137
11441138      xscale = xdim / 16;
r20746r20747
11571151      if (flipy)  { ystart = ynum-1;  yend = -1;    yinc = -1; }
11581152      else        { ystart = 0;       yend = ynum;  yinc = +1; }
11591153
1160      state->m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
1154      m_drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
11611155
11621156      for (y = ystart; y != yend; y += yinc)
11631157      {
11641158         for (x = xstart; x != xend; x += xinc)
11651159         {
1166            drawgfxzoom_transtable(bitmap,cliprect,machine.gfx[3],
1160            drawgfxzoom_transtable(bitmap,cliprect,machine().gfx[3],
11671161                     code++,
11681162                     color,
11691163                     flipx,flipy,
11701164                     (sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000,
1171                     xscale, yscale, state->m_drawmode_table, machine.shadow_table);
1165                     xscale, yscale, m_drawmode_table, machine().shadow_table);
11721166         }
11731167      }
11741168#ifdef MAME_DEBUG
11751169#if 0
1176if (machine.input().code_pressed(KEYCODE_X))
1170if (machine().input().code_pressed(KEYCODE_X))
11771171{   /* Display some info on each sprite */
11781172   sprintf(buf, "%04x",attr);
11791173   ui_draw_text(buf, sx>>16, sy>>16);
r20746r20747
12531247
12541248   for (i = 7; i >= 4; i--)
12551249   {                                           /* bitmap, road, min_priority, max_priority, transparency */
1256      if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,i,i,FALSE);
1257      if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,i,i,TRUE);
1250      if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,i,i,FALSE);
1251      if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,i,i,TRUE);
12581252   }
12591253
12601254   flag = 0;
r20746r20747
12631257
12641258   for (i = 3; i >= 0; i--)
12651259   {                                           /* bitmap, road, min_priority, max_priority, transparency */
1266      if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,i,i,TRUE);
1267      if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,i,i,TRUE);
1260      if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,i,i,TRUE);
1261      if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,i,i,TRUE);
12681262   }
12691263
1270   if (m_active_layers & 0x08) bigrun_draw_sprites(machine(),bitmap,cliprect,15,0);
1264   if (m_active_layers & 0x08) bigrun_draw_sprites(bitmap,cliprect,15,0);
12711265
12721266   cischeat_tmap_DRAW(2)
12731267
r20746r20747
13051299   bitmap.fill(0, cliprect);
13061300
13071301                              /* bitmap, road, priority, transparency */
1308   if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,7,5,FALSE);
1309   if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,7,5,TRUE);
1302   if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,7,5,FALSE);
1303   if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,7,5,TRUE);
13101304
13111305   flag = 0;
13121306   cischeat_tmap_DRAW(0)
13131307//  else bitmap.fill(0, cliprect);
13141308   cischeat_tmap_DRAW(1)
13151309
1316   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,15,3);
1317   if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,4,1,TRUE);
1318   if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,4,1,TRUE);
1319   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,2,2);
1320   if (m_active_layers & 0x10) cischeat_draw_road(machine(),bitmap,cliprect,0,0,0,TRUE);
1321   if (m_active_layers & 0x20) cischeat_draw_road(machine(),bitmap,cliprect,1,0,0,TRUE);
1322   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,1,0);
1310   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,15,3);
1311   if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,4,1,TRUE);
1312   if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,4,1,TRUE);
1313   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,2,2);
1314   if (m_active_layers & 0x10) cischeat_draw_road(bitmap,cliprect,0,0,0,TRUE);
1315   if (m_active_layers & 0x20) cischeat_draw_road(bitmap,cliprect,1,0,0,TRUE);
1316   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,1,0);
13231317   cischeat_tmap_DRAW(2)
13241318
13251319   /* for the map screen */
1326   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,0+16,0+16);
1320   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,0+16,0+16);
13271321
13281322
13291323   m_active_layers = active_layers1;
r20746r20747
13631357/*  1: clouds 5, grad 7, road 0     2: clouds 5, grad 7, road 0, tunnel roof 0 */
13641358
13651359   /* road 1!! 0!! */                  /* bitmap, road, min_priority, max_priority, transparency */
1366   if (m_active_layers & 0x20) f1gpstar_draw_road(machine(),bitmap,cliprect,1,6,7,TRUE);
1367   if (m_active_layers & 0x10) f1gpstar_draw_road(machine(),bitmap,cliprect,0,6,7,TRUE);
1360   if (m_active_layers & 0x20) f1gpstar_draw_road(bitmap,cliprect,1,6,7,TRUE);
1361   if (m_active_layers & 0x10) f1gpstar_draw_road(bitmap,cliprect,0,6,7,TRUE);
13681362
13691363   flag = 0;
13701364   cischeat_tmap_DRAW(0)
r20746r20747
13721366   cischeat_tmap_DRAW(1)
13731367
13741368   /* road 1!! 0!! */                  /* bitmap, road, min_priority, max_priority, transparency */
1375   if (m_active_layers & 0x20) f1gpstar_draw_road(machine(),bitmap,cliprect,1,1,5,TRUE);
1376   if (m_active_layers & 0x10) f1gpstar_draw_road(machine(),bitmap,cliprect,0,1,5,TRUE);
1369   if (m_active_layers & 0x20) f1gpstar_draw_road(bitmap,cliprect,1,1,5,TRUE);
1370   if (m_active_layers & 0x10) f1gpstar_draw_road(bitmap,cliprect,0,1,5,TRUE);
13771371
1378   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,15,2);
1372   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,15,2);
13791373
13801374   /* road 1!! 0!! */                  /* bitmap, road, min_priority, max_priority, transparency */
1381   if (m_active_layers & 0x20) f1gpstar_draw_road(machine(),bitmap,cliprect,1,0,0,TRUE);
1382   if (m_active_layers & 0x10) f1gpstar_draw_road(machine(),bitmap,cliprect,0,0,0,TRUE);
1375   if (m_active_layers & 0x20) f1gpstar_draw_road(bitmap,cliprect,1,0,0,TRUE);
1376   if (m_active_layers & 0x10) f1gpstar_draw_road(bitmap,cliprect,0,0,0,TRUE);
13831377
1384   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,1,1);
1378   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,1,1);
13851379   cischeat_tmap_DRAW(2)
1386   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,0,0);
1380   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,0,0);
13871381
13881382
13891383   m_active_layers = active_layers1;
r20746r20747
14391433   flag = 0;
14401434   cischeat_tmap_DRAW(0)
14411435   // no layer 1
1442   if (m_active_layers & 0x08) cischeat_draw_sprites(machine(),bitmap,cliprect,0,15);
1436   if (m_active_layers & 0x08) cischeat_draw_sprites(bitmap,cliprect,0,15);
14431437   cischeat_tmap_DRAW(2)
14441438
14451439   m_active_layers = active_layers1;
trunk/src/mame/video/cvs.c
r20746r20747
6565}
6666
6767
68static void set_pens( running_machine &machine )
68void cvs_state::set_pens(  )
6969{
70   cvs_state *state = machine.driver_data<cvs_state>();
7170   int i;
7271
7372   for (i = 0; i < 0x10; i++)
7473   {
75      int r = pal2bit(~state->m_palette_ram[i] >> 0);
76      int g = pal3bit(~state->m_palette_ram[i] >> 2);
77      int b = pal3bit(~state->m_palette_ram[i] >> 5);
74      int r = pal2bit(~m_palette_ram[i] >> 0);
75      int g = pal3bit(~m_palette_ram[i] >> 2);
76      int b = pal3bit(~m_palette_ram[i] >> 5);
7877
79      colortable_palette_set_color(machine.colortable, i, MAKE_RGB(r, g, b));
78      colortable_palette_set_color(machine().colortable, i, MAKE_RGB(r, g, b));
8079   }
8180}
8281
r20746r20747
122121
123122VIDEO_START_MEMBER(cvs_state,cvs)
124123{
125   cvs_init_stars(machine());
124   cvs_init_stars();
126125
127126   /* create helper bitmaps */
128127   machine().primary_screen->register_screen_bitmap(m_background_bitmap);
r20746r20747
142141   offs_t offs;
143142   int scroll[8];
144143
145   set_pens(machine());
144   set_pens();
146145
147146   /* draw the background */
148147   for (offs = 0; offs < 0x0400; offs++)
r20746r20747
262261
263262   /* stars circuit */
264263   if (m_stars_on)
265      cvs_update_stars(machine(), bitmap, cliprect, BULLET_STAR_PEN, 0);
264      cvs_update_stars(bitmap, cliprect, BULLET_STAR_PEN, 0);
266265
267266   return 0;
268267}
r20746r20747
271270
272271/* cvs stars hardware */
273272
274void cvs_scroll_stars( running_machine &machine )
273void cvs_state::cvs_scroll_stars(  )
275274{
276   cvs_state *state = machine.driver_data<cvs_state>();
277   state->m_stars_scroll++;
275   m_stars_scroll++;
278276}
279277
280void cvs_init_stars( running_machine &machine )
278void cvs_state::cvs_init_stars(  )
281279{
282   cvs_state *state = machine.driver_data<cvs_state>();
283280   int generator = 0;
284281   int x, y;
285282
286283   /* precalculate the star background */
287284
288   state->m_total_stars = 0;
285   m_total_stars = 0;
289286
290287   for (y = 255; y >= 0; y--)
291288   {
r20746r20747
304301         {
305302            if(((~(generator >> 12)) & 0x01) && ((~(generator >> 13)) & 0x01))
306303            {
307               if (state->m_total_stars < CVS_MAX_STARS)
304               if (m_total_stars < CVS_MAX_STARS)
308305               {
309                  state->m_stars[state->m_total_stars].x = x;
310                  state->m_stars[state->m_total_stars].y = y;
311                  state->m_stars[state->m_total_stars].code = 1;
306                  m_stars[m_total_stars].x = x;
307                  m_stars[m_total_stars].y = y;
308                  m_stars[m_total_stars].code = 1;
312309
313                  state->m_total_stars++;
310                  m_total_stars++;
314311               }
315312            }
316313         }
r20746r20747
318315   }
319316}
320317
321void cvs_update_stars(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const pen_t star_pen, bool update_always)
318void cvs_state::cvs_update_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, const pen_t star_pen, bool update_always)
322319{
323   cvs_state *state = machine.driver_data<cvs_state>();
324   for (int offs = 0; offs < state->m_total_stars; offs++)
320   for (int offs = 0; offs < m_total_stars; offs++)
325321   {
326      UINT8 x = (state->m_stars[offs].x + state->m_stars_scroll) >> 1;
327      UINT8 y = state->m_stars[offs].y + ((state->m_stars_scroll + state->m_stars[offs].x) >> 9);
322      UINT8 x = (m_stars[offs].x + m_stars_scroll) >> 1;
323      UINT8 y = m_stars[offs].y + ((m_stars_scroll + m_stars[offs].x) >> 9);
328324
329325      if ((y & 1) ^ ((x >> 4) & 1))
330326      {
331         if (state->flip_screen_x())
327         if (flip_screen_x())
332328            x = ~x;
333329
334         if (state->flip_screen_y())
330         if (flip_screen_y())
335331            y = ~y;
336332
337333         if ((y >= cliprect.min_y) && (y <= cliprect.max_y) &&
338            (update_always || (colortable_entry_get_value(machine.colortable, bitmap.pix16(y, x)) == 0)))
334            (update_always || (colortable_entry_get_value(machine().colortable, bitmap.pix16(y, x)) == 0)))
339335            bitmap.pix16(y, x) = star_pen;
340336      }
341337   }
trunk/src/mame/video/centiped.c
r20746r20747
6363 *
6464 *************************************/
6565
66static void init_penmask(running_machine &machine)
66void centiped_state::init_penmask()
6767{
68   centiped_state *state = machine.driver_data<centiped_state>();
6968   int i;
7069
7170   for (i = 0; i < 64; i++)
r20746r20747
7473      if (((i >> 0) & 3) == 0) mask |= 2;
7574      if (((i >> 2) & 3) == 0) mask |= 4;
7675      if (((i >> 4) & 3) == 0) mask |= 8;
77      state->m_penmask[i] = mask;
76      m_penmask[i] = mask;
7877   }
7978}
8079
8180
82static void init_common(running_machine &machine)
81void centiped_state::init_common()
8382{
84   centiped_state *state = machine.driver_data<centiped_state>();
8583
86   state->save_item(NAME(state->m_flipscreen));
87   state->save_item(NAME(state->m_gfx_bank));
88   state->save_item(NAME(state->m_bullsdrt_sprites_bank));
84   save_item(NAME(m_flipscreen));
85   save_item(NAME(m_gfx_bank));
86   save_item(NAME(m_bullsdrt_sprites_bank));
8987
90   state->m_flipscreen = 0;
91   state->m_gfx_bank = 0;
92   state->m_bullsdrt_sprites_bank = 0;
88   m_flipscreen = 0;
89   m_gfx_bank = 0;
90   m_bullsdrt_sprites_bank = 0;
9391}
9492
9593
9694VIDEO_START_MEMBER(centiped_state,centiped)
9795{
98   init_common(machine());
99   init_penmask(machine());
96   init_common();
97   init_penmask();
10098
10199   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(centiped_state::centiped_get_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
102100}
r20746r20747
104102
105103VIDEO_START_MEMBER(centiped_state,warlords)
106104{
107   init_common(machine());
105   init_common();
108106
109107   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(centiped_state::warlords_get_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
110108}
r20746r20747
112110
113111VIDEO_START_MEMBER(centiped_state,milliped)
114112{
115   init_common(machine());
116   init_penmask(machine());
113   init_common();
114   init_penmask();
117115
118116   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(centiped_state::milliped_get_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
119117}
r20746r20747
121119
122120VIDEO_START_MEMBER(centiped_state,bullsdrt)
123121{
124   init_common(machine());
125   init_penmask(machine());
122   init_common();
123   init_penmask();
126124
127125   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(centiped_state::bullsdrt_get_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
128126}
r20746r20747
339337
340338***************************************************************************/
341339
342static void milliped_set_color(running_machine &machine, offs_t offset, UINT8 data)
340void centiped_state::milliped_set_color(offs_t offset, UINT8 data)
343341{
344342   rgb_t color;
345343   int bit0, bit1, bit2;
r20746r20747
367365
368366   /* character colors, set directly */
369367   if (offset < 0x10)
370      palette_set_color(machine, offset, color);
368      palette_set_color(machine(), offset, color);
371369
372370   /* sprite colors - set all the applicable ones */
373371   else
r20746r20747
381379      for (i = (base << 6); i < (base << 6) + 0x100; i += 4)
382380      {
383381         if (offset == ((i >> 2) & 0x03))
384            palette_set_color(machine, i + 0x10 + 1, color);
382            palette_set_color(machine(), i + 0x10 + 1, color);
385383
386384         if (offset == ((i >> 4) & 0x03))
387            palette_set_color(machine, i + 0x10 + 2, color);
385            palette_set_color(machine(), i + 0x10 + 2, color);
388386
389387         if (offset == ((i >> 6) & 0x03))
390            palette_set_color(machine, i + 0x10 + 3, color);
388            palette_set_color(machine(), i + 0x10 + 3, color);
391389      }
392390   }
393391}
r20746r20747
397395{
398396   m_generic_paletteram_8[offset] = data;
399397
400   milliped_set_color(machine(), offset, data);
398   milliped_set_color(offset, data);
401399}
402400
403401
r20746r20747
406404   m_generic_paletteram_8[offset] = data;
407405
408406   /* the value passed in is a look-up index into the color PROM */
409   milliped_set_color(machine(), offset, ~machine().root_device().memregion("proms")->base()[~data & 0x0f]);
407   milliped_set_color(offset, ~machine().root_device().memregion("proms")->base()[~data & 0x0f]);
410408}
411409
412410
trunk/src/mame/video/circus.c
r20746r20747
3939   m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(circus_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
4040}
4141
42static void draw_line( bitmap_ind16 &bitmap, const rectangle &cliprect, int x1, int y1, int x2, int y2, int dotted )
42void circus_state::draw_line( bitmap_ind16 &bitmap, const rectangle &cliprect, int x1, int y1, int x2, int y2, int dotted )
4343{
4444   /* Draws horizontal and Vertical lines only! */
4545   int count, skip;
r20746r20747
5858         bitmap.pix16(y1, count) = 1;
5959}
6060
61static void draw_sprite_collision( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
61void circus_state::draw_sprite_collision( bitmap_ind16 &bitmap, const rectangle &cliprect )
6262{
63   circus_state *state = machine.driver_data<circus_state>();
64   gfx_element *sprite_gfx = machine.gfx[1];
65   const UINT8 *sprite_data = sprite_gfx->get_data(state->m_clown_z);
63   gfx_element *sprite_gfx = machine().gfx[1];
64   const UINT8 *sprite_data = sprite_gfx->get_data(m_clown_z);
6665   int sx, sy, dx, dy;
6766   int pixel, collision = 0;
6867
6968   // draw sprite and check collision on a pixel basis
7069   for (sy = 0; sy < 16; sy++)
7170   {
72      dy = state->m_clown_x + sy-1;
71      dy = m_clown_x + sy-1;
7372      if (dy>=0 && dy<bitmap.height())
7473      {
7574         for (sx = 0; sx < 16; sx++)
7675         {
77            dx = state->m_clown_y + sx;
76            dx = m_clown_y + sx;
7877            if (dx>=0 && dx<bitmap.width())
7978            {
8079               pixel = sprite_data[sy * sprite_gfx->rowbytes() + sx];
8180               if (pixel)
8281               {
8382                  collision |= bitmap.pix16(dy, dx);
84                  bitmap.pix16(dy, dx) = machine.pens[pixel];
83                  bitmap.pix16(dy, dx) = machine().pens[pixel];
8584               }
8685            }
8786         }
r20746r20747
8988   }
9089
9190   if (collision)
92      state->m_maincpu->set_input_line(0, ASSERT_LINE);
91      m_maincpu->set_input_line(0, ASSERT_LINE);
9392}
9493
95static void circus_draw_fg( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
94void circus_state::circus_draw_fg( bitmap_ind16 &bitmap, const rectangle &cliprect )
9695{
9796   /* The sync generator hardware is used to   */
9897   /* draw the border and diving boards        */
r20746r20747
111110UINT32 circus_state::screen_update_circus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
112111{
113112   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
114   circus_draw_fg(machine(), bitmap, cliprect);
115   draw_sprite_collision(machine(), bitmap, cliprect);
113   circus_draw_fg(bitmap, cliprect);
114   draw_sprite_collision(bitmap, cliprect);
116115   return 0;
117116}
118117
119static void robotbwl_draw_box( bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y )
118void circus_state::robotbwl_draw_box( bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y )
120119{
121120   /* Box */
122121   int ex = x + 24;
r20746r20747
134133   draw_line(bitmap, cliprect, x + 16, y, x + 16, ey, 0);
135134}
136135
137static void robotbwl_draw_scoreboard( bitmap_ind16 &bitmap, const rectangle &cliprect )
136void circus_state::robotbwl_draw_scoreboard( bitmap_ind16 &bitmap, const rectangle &cliprect )
138137{
139138   int offs;
140139
r20746r20747
159158   draw_line(bitmap, cliprect, 39 + 152, 137, 47 + 152, 137, 0);
160159}
161160
162static void robotbwl_draw_bowling_alley( bitmap_ind16 &bitmap, const rectangle &cliprect )
161void circus_state::robotbwl_draw_bowling_alley( bitmap_ind16 &bitmap, const rectangle &cliprect )
163162{
164163   draw_line(bitmap, cliprect, 103, 17, 103, 205, 0);
165164   draw_line(bitmap, cliprect, 111, 17, 111, 203, 1);
r20746r20747
167166   draw_line(bitmap, cliprect, 144, 17, 144, 203, 1);
168167}
169168
170static void robotbwl_draw_ball( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
169void circus_state::robotbwl_draw_ball( bitmap_ind16 &bitmap, const rectangle &cliprect )
171170{
172   circus_state *state = machine.driver_data<circus_state>();
173171   drawgfx_transpen(bitmap,/* Y is horizontal position */
174         cliprect,machine.gfx[1],
175         state->m_clown_z,
172         cliprect,machine().gfx[1],
173         m_clown_z,
176174         0,
177175         0,0,
178         state->m_clown_y + 8, state->m_clown_x + 8, 0);
176         m_clown_y + 8, m_clown_x + 8, 0);
179177}
180178
181179UINT32 circus_state::screen_update_robotbwl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20746r20747
183181   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
184182   robotbwl_draw_scoreboard(bitmap, cliprect);
185183   robotbwl_draw_bowling_alley(bitmap, cliprect);
186   robotbwl_draw_ball(machine(), bitmap, cliprect);
184   robotbwl_draw_ball(bitmap, cliprect);
187185   return 0;
188186}
189187
190static void crash_draw_car( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
188void circus_state::crash_draw_car( bitmap_ind16 &bitmap, const rectangle &cliprect )
191189{
192   circus_state *state = machine.driver_data<circus_state>();
193190   drawgfx_transpen(bitmap,/* Y is horizontal position */
194      cliprect,machine.gfx[1],
195      state->m_clown_z,
191      cliprect,machine().gfx[1],
192      m_clown_z,
196193      0,
197194      0,0,
198      state->m_clown_y, state->m_clown_x - 1, 0);
195      m_clown_y, m_clown_x - 1, 0);
199196}
200197
201198UINT32 circus_state::screen_update_crash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
202199{
203200   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
204   crash_draw_car(machine(), bitmap, cliprect);
201   crash_draw_car(bitmap, cliprect);
205202   return 0;
206203}
207204
208205UINT32 circus_state::screen_update_ripcord(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
209206{
210207   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
211   draw_sprite_collision(machine(), bitmap, cliprect);
208   draw_sprite_collision(bitmap, cliprect);
212209   return 0;
213210}
trunk/src/mame/video/commando.c
r20746r20747
8787   m_fg_tilemap->set_transparent_pen(3);
8888}
8989
90static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
90void commando_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
9191{
92   commando_state *state = machine.driver_data<commando_state>();
93   UINT8 *buffered_spriteram = state->m_spriteram->buffer();
92   UINT8 *buffered_spriteram = m_spriteram->buffer();
9493   int offs;
9594
96   for (offs = state->m_spriteram->bytes() - 4; offs >= 0; offs -= 4)
95   for (offs = m_spriteram->bytes() - 4; offs >= 0; offs -= 4)
9796   {
9897      // bit 1 of attr is not used
9998      int attr = buffered_spriteram[offs + 1];
r20746r20747
105104      int sx = buffered_spriteram[offs + 3] - ((attr & 0x01) << 8);
106105      int sy = buffered_spriteram[offs + 2];
107106
108      if (state->flip_screen())
107      if (flip_screen())
109108      {
110109         sx = 240 - sx;
111110         sy = 240 - sy;
r20746r20747
114113      }
115114
116115      if (bank < 3)
117         drawgfx_transpen(bitmap, cliprect, machine.gfx[2], code, color, flipx, flipy, sx, sy, 15);
116         drawgfx_transpen(bitmap, cliprect, machine().gfx[2], code, color, flipx, flipy, sx, sy, 15);
118117   }
119118}
120119
121120UINT32 commando_state::screen_update_commando(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
122121{
123122   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
124   draw_sprites(machine(), bitmap, cliprect);
123   draw_sprites(bitmap, cliprect);
125124   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
126125   return 0;
127126}
trunk/src/mame/video/cloak.c
r20746r20747
4444}
4545
4646
47static void set_pens(running_machine &machine)
47void cloak_state::set_pens()
4848{
49   cloak_state *state = machine.driver_data<cloak_state>();
50   UINT16 *palette_ram = state->m_palette_ram;
49   UINT16 *palette_ram = m_palette_ram;
5150   static const int resistances[3] = { 10000, 4700, 2200 };
5251   double weights[3];
5352   int i;
r20746r20747
8180      bit2 = (~palette_ram[i] >> 2) & 0x01;
8281      b = combine_3_weights(weights, bit0, bit1, bit2);
8382
84      palette_set_color(machine, i, MAKE_RGB(r, g, b));
83      palette_set_color(machine(), i, MAKE_RGB(r, g, b));
8584   }
8685}
8786
r20746r20747
178177   machine().save().register_postload(save_prepost_delegate(FUNC(cloak_state::set_current_bitmap_videoram_pointer), this));
179178}
180179
181static void draw_bitmap(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
180void cloak_state::draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect)
182181{
183   cloak_state *state = machine.driver_data<cloak_state>();
184182   int x, y;
185183
186184   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
187185      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
188186      {
189         pen_t pen = state->m_current_bitmap_videoram_displayed[(y << 8) | x] & 0x07;
187         pen_t pen = m_current_bitmap_videoram_displayed[(y << 8) | x] & 0x07;
190188
191189         if (pen)
192190            bitmap.pix16(y, (x - 6) & 0xff) = 0x10 | ((x & 0x80) >> 4) | pen;
193191      }
194192}
195193
196static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
194void cloak_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
197195{
198   cloak_state *state = machine.driver_data<cloak_state>();
199   UINT8 *spriteram = state->m_spriteram;
196   UINT8 *spriteram = m_spriteram;
200197   int offs;
201198
202199   for (offs = (0x100 / 4) - 1; offs >= 0; offs--)
r20746r20747
207204      int sx = spriteram[offs + 192];
208205      int sy = 240 - spriteram[offs];
209206
210      if (state->flip_screen())
207      if (flip_screen())
211208      {
212209         sx -= 9;
213210         sy = 240 - sy;
r20746r20747
215212         flipy = !flipy;
216213      }
217214
218      drawgfx_transpen(bitmap, cliprect, machine.gfx[1], code, 0, flipx, flipy,   sx, sy, 0);
215      drawgfx_transpen(bitmap, cliprect, machine().gfx[1], code, 0, flipx, flipy,   sx, sy, 0);
219216   }
220217}
221218
222219UINT32 cloak_state::screen_update_cloak(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
223220{
224   set_pens(machine());
221   set_pens();
225222   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
226   draw_bitmap(machine(), bitmap, cliprect);
227   draw_sprites(machine(), bitmap, cliprect);
223   draw_bitmap(bitmap, cliprect);
224   draw_sprites(bitmap, cliprect);
228225   return 0;
229226}
trunk/src/mame/video/cloud9.c
r20746r20747
105105 *
106106 *************************************/
107107
108INLINE void cloud9_write_vram( running_machine &machine, UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
108inline void cloud9_state::cloud9_write_vram( UINT16 addr, UINT8 data, UINT8 bitmd, UINT8 pixba )
109109{
110   cloud9_state *state = machine.driver_data<cloud9_state>();
111   UINT8 *dest = &state->m_videoram[0x0000 | (addr & 0x3fff)];
112   UINT8 *dest2 = &state->m_videoram[0x4000 | (addr & 0x3fff)];
110   UINT8 *dest = &m_videoram[0x0000 | (addr & 0x3fff)];
111   UINT8 *dest2 = &m_videoram[0x4000 | (addr & 0x3fff)];
113112   UINT8 promaddr = 0;
114113   UINT8 wpbits;
115114
r20746r20747
126125       Bit 0 = PIXA
127126   */
128127   promaddr |= bitmd << 7;
129   promaddr |= state->m_video_control[4] << 6;
130   promaddr |= state->m_video_control[6] << 5;
128   promaddr |= m_video_control[4] << 6;
129   promaddr |= m_video_control[6] << 5;
131130   promaddr |= ((addr & 0xf000) != 0x4000) << 4;
132131   promaddr |= ((addr & 0x3800) == 0x0000) << 3;
133132   promaddr |= ((addr & 0x0600) == 0x0600) << 2;
134133   promaddr |= (pixba << 0);
135134
136135   /* look up the PROM result */
137   wpbits = state->m_wpprom[promaddr];
136   wpbits = m_wpprom[promaddr];
138137
139138   /* write to the appropriate parts of VRAM depending on the result */
140139   if (!(wpbits & 1))
r20746r20747
155154 *
156155 *************************************/
157156
158INLINE void bitmode_autoinc( running_machine &machine )
157inline void cloud9_state::bitmode_autoinc(  )
159158{
160   cloud9_state *state = machine.driver_data<cloud9_state>();
161159
162160   /* auto increment in the x-direction if it's enabled */
163   if (!state->m_video_control[0]) /* /AX */
164      state->m_bitmode_addr[0]++;
161   if (!m_video_control[0]) /* /AX */
162      m_bitmode_addr[0]++;
165163
166164   /* auto increment in the y-direction if it's enabled */
167   if (!state->m_video_control[1]) /* /AY */
168      state->m_bitmode_addr[1]++;
165   if (!m_video_control[1]) /* /AY */
166      m_bitmode_addr[1]++;
169167}
170168
171169
r20746r20747
179177WRITE8_MEMBER(cloud9_state::cloud9_videoram_w)
180178{
181179   /* direct writes to VRAM go through the write protect PROM as well */
182   cloud9_write_vram(machine(), offset, data, 0, 0);
180   cloud9_write_vram(offset, data, 0, 0);
183181}
184182
185183
r20746r20747
199197   UINT8 result = m_videoram[((~m_bitmode_addr[0] & 2) << 13) | addr] << ((m_bitmode_addr[0] & 1) * 4);
200198
201199   /* autoincrement because /BITMD was selected */
202   bitmode_autoinc(machine());
200   bitmode_autoinc();
203201
204202   /* the upper 4 bits of the data lines are not driven so make them all 1's */
205203   return (result >> 4) | 0xf0;
r20746r20747
215213   data = (data & 0x0f) | (data << 4);
216214
217215   /* write through the generic VRAM routine, passing the low 2 X bits as PIXB/PIXA */
218   cloud9_write_vram(machine(), addr, data, 1, m_bitmode_addr[0] & 3);
216   cloud9_write_vram(addr, data, 1, m_bitmode_addr[0] & 3);
219217
220218   /* autoincrement because /BITMD was selected */
221   bitmode_autoinc(machine());
219   bitmode_autoinc();
222220}
223221
224222
225223WRITE8_MEMBER(cloud9_state::cloud9_bitmode_addr_w)
226224{
227225   /* write through to video RAM and also to the addressing latches */
228   cloud9_write_vram(machine(), offset, data, 0, 0);
226   cloud9_write_vram(offset, data, 0, 0);
229227   m_bitmode_addr[offset] = data;
230228}
231229
trunk/src/mame/video/cheekyms.c
r20746r20747
103103}
104104
105105
106static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, int flip )
106void cheekyms_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx, int flip )
107107{
108   cheekyms_state *state = machine.driver_data<cheekyms_state>();
109108   offs_t offs;
110109
111110   for (offs = 0; offs < 0x20; offs += 4)
112111   {
113112      int x, y, code, color;
114113
115      if ((state->m_spriteram[offs + 3] & 0x08) == 0x00) continue;
114      if ((m_spriteram[offs + 3] & 0x08) == 0x00) continue;
116115
117      x  = 256 - state->m_spriteram[offs + 2];
118      y  = state->m_spriteram[offs + 1];
119      code =  (~state->m_spriteram[offs + 0] & 0x0f) << 1;
120      color = (~state->m_spriteram[offs + 3] & 0x07);
116      x  = 256 - m_spriteram[offs + 2];
117      y  = m_spriteram[offs + 1];
118      code =  (~m_spriteram[offs + 0] & 0x0f) << 1;
119      color = (~m_spriteram[offs + 3] & 0x07);
121120
122      if (state->m_spriteram[offs + 0] & 0x80)
121      if (m_spriteram[offs + 0] & 0x80)
123122      {
124123         if (!flip)
125124            code++;
r20746r20747
128127      }
129128      else
130129      {
131         if (state->m_spriteram[offs + 0] & 0x02)
130         if (m_spriteram[offs + 0] & 0x02)
132131         {
133132            drawgfx_transpen(bitmap, cliprect, gfx, code | 0x20, color, 0, 0,        x, y, 0);
134133            drawgfx_transpen(bitmap, cliprect, gfx, code | 0x21, color, 0, 0, 0x10 + x, y, 0);
r20746r20747
156155   m_bitmap_buffer->fill(0, cliprect);
157156
158157   /* sprites go under the playfield */
159   draw_sprites(machine(), bitmap, cliprect, machine().gfx[1], flip);
158   draw_sprites(bitmap, cliprect, machine().gfx[1], flip);
160159
161160   /* draw the tilemap to a temp bitmap */
162161   m_cm_tilemap->draw(*m_bitmap_buffer, cliprect, 0, 0);
trunk/src/mame/drivers/cischeat.c
r20746r20747
17811781
17821782    We need to untangle it
17831783*/
1784static void cischeat_untangle_sprites(running_machine &machine, const char *region)
1784void cischeat_state::cischeat_untangle_sprites(const char *region)
17851785{
1786   UINT8       *src = machine.root_device().memregion(region)->base();
1787   const UINT8 *end = src + machine.root_device().memregion(region)->bytes();
1786   UINT8       *src = machine().root_device().memregion(region)->base();
1787   const UINT8 *end = src + machine().root_device().memregion(region)->bytes();
17881788
17891789   while (src < end)
17901790   {
r20746r20747
19361936
19371937DRIVER_INIT_MEMBER(cischeat_state,bigrun)
19381938{
1939   cischeat_untangle_sprites(machine(), "gfx4");   // Untangle sprites
1939   cischeat_untangle_sprites("gfx4");   // Untangle sprites
19401940   phantasm_rom_decode(machine(), "soundcpu");                 // Decrypt sound cpu code
19411941}
19421942
r20746r20747
20552055
20562056DRIVER_INIT_MEMBER(cischeat_state,cischeat)
20572057{
2058   cischeat_untangle_sprites(machine(), "gfx4");   // Untangle sprites
2058   cischeat_untangle_sprites("gfx4");   // Untangle sprites
20592059   astyanax_rom_decode(machine(), "soundcpu");                 // Decrypt sound cpu code
20602060}
20612061
r20746r20747
22692269
22702270DRIVER_INIT_MEMBER(cischeat_state,f1gpstar)
22712271{
2272   cischeat_untangle_sprites(machine(), "gfx4");
2272   cischeat_untangle_sprites("gfx4");
22732273}
22742274
22752275
trunk/src/mame/drivers/centiped.c
r20746r20747
512512 * to prevent the counter from wrapping around between reads.
513513 */
514514
515INLINE int read_trackball(running_machine &machine, int idx, int switch_port)
515inline int centiped_state::read_trackball(int idx, int switch_port)
516516{
517   centiped_state *state = machine.driver_data<centiped_state>();
518517   UINT8 newpos;
519518   static const char *const portnames[] = { "IN0", "IN1", "IN2" };
520519   static const char *const tracknames[] = { "TRACK0_X", "TRACK0_Y", "TRACK1_X", "TRACK1_Y" };
521520
522521   /* adjust idx if we're cocktail flipped */
523   if (state->m_flipscreen)
522   if (m_flipscreen)
524523      idx += 2;
525524
526525   /* if we're to read the dipswitches behind the trackball data, do it now */
527   if (state->m_dsw_select)
528      return (machine.root_device().ioport(portnames[switch_port])->read() & 0x7f) | state->m_sign[idx];
526   if (m_dsw_select)
527      return (machine().root_device().ioport(portnames[switch_port])->read() & 0x7f) | m_sign[idx];
529528
530529   /* get the new position and adjust the result */
531   newpos = machine.root_device().ioport(tracknames[idx])->read();
532   if (newpos != state->m_oldpos[idx])
530   newpos = machine().root_device().ioport(tracknames[idx])->read();
531   if (newpos != m_oldpos[idx])
533532   {
534      state->m_sign[idx] = (newpos - state->m_oldpos[idx]) & 0x80;
535      state->m_oldpos[idx] = newpos;
533      m_sign[idx] = (newpos - m_oldpos[idx]) & 0x80;
534      m_oldpos[idx] = newpos;
536535   }
537536
538537   /* blend with the bits from the switch port */
539   return (machine.root_device().ioport(portnames[switch_port])->read() & 0x70) | (state->m_oldpos[idx] & 0x0f) | state->m_sign[idx];
538   return (machine().root_device().ioport(portnames[switch_port])->read() & 0x70) | (m_oldpos[idx] & 0x0f) | m_sign[idx];
540539}
541540
542541
543542READ8_MEMBER(centiped_state::centiped_IN0_r)
544543{
545   return read_trackball(machine(), 0, 0);
544   return read_trackball(0, 0);
546545}
547546
548547
549548READ8_MEMBER(centiped_state::centiped_IN2_r)
550549{
551   return read_trackball(machine(), 1, 2);
550   return read_trackball(1, 2);
552551}
553552
554553
555554READ8_MEMBER(centiped_state::milliped_IN1_r)
556555{
557   return read_trackball(machine(), 1, 1);
556   return read_trackball(1, 1);
558557}
559558
560559READ8_MEMBER(centiped_state::milliped_IN2_r)
trunk/src/mame/drivers/cvs.c
r20746r20747
221221   device.execute().set_input_line_vector(0, 0x03);
222222   generic_pulse_irq_line(device.execute(), 0, 1);
223223
224   cvs_scroll_stars(machine());
224   cvs_scroll_stars();
225225}
226226
227227
r20746r20747
296296}
297297
298298
299static void start_393hz_timer(running_machine &machine)
299void cvs_state::start_393hz_timer()
300300{
301   cvs_state *state = machine.driver_data<cvs_state>();
302   state->m_cvs_393hz_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(cvs_state::cvs_393hz_timer_cb),state));
303   state->m_cvs_393hz_timer->adjust(attotime::from_hz(30*393), 0, attotime::from_hz(30*393));
301   m_cvs_393hz_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cvs_state::cvs_393hz_timer_cb),this));
302   m_cvs_393hz_timer->adjust(attotime::from_hz(30*393), 0, attotime::from_hz(30*393));
304303}
305304
306305
r20746r20747
980979   if (machine().gfx[1] != NULL)
981980      machine().gfx[1]->set_source(m_character_ram);
982981
983   start_393hz_timer(machine());
982   start_393hz_timer();
984983
985984   /* set devices */
986985   m_maincpu = machine().device<cpu_device>("maincpu");
trunk/src/mame/drivers/cps3.c
r20746r20747
408408#define CPS3_TRANSPARENCY_PEN_INDEX 2
409409#define CPS3_TRANSPARENCY_PEN_INDEX_BLEND 3
410410
411static void copy_from_nvram(running_machine &machine);
412
413INLINE void cps3_drawgfxzoom(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
411inline void cps3_state::cps3_drawgfxzoom(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
414412      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
415413      int transparency,int transparent_color,
416414      int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask)
417415{
418   cps3_state *state = gfx->machine().driver_data<cps3_state>();
419416   rectangle myclip;
420417
421418//  UINT8 al;
r20746r20747
449446      {
450447//          const pen_t *pal = &gfx->colortable[gfx->granularity() * (color % gfx->colors())];
451448         UINT32 palbase = (gfx->granularity() * color) & 0x1ffff;
452         const pen_t *pal = &state->m_mame_colours[palbase];
449         const pen_t *pal = &m_mame_colours[palbase];
453450         const UINT8 *source_base = gfx->get_data(code % gfx->elements());
454451
455452         int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16;
r20746r20747
625622/* Encryption */
626623
627624
628static UINT16 rotate_left(UINT16 value, int n)
625UINT16 cps3_state::rotate_left(UINT16 value, int n)
629626{
630627   int aux = value>>(16-n);
631628   return ((value<<n)|aux)%0x10000;
632629}
633630
634static UINT16 rotxor(UINT16 val, UINT16 xorval)
631UINT16 cps3_state::rotxor(UINT16 val, UINT16 xorval)
635632{
636633   UINT16 res;
637634
r20746r20747
642639   return res;
643640}
644641
645static UINT32 cps3_mask(UINT32 address, UINT32 key1, UINT32 key2)
642UINT32 cps3_state::cps3_mask(UINT32 address, UINT32 key1, UINT32 key2)
646643{
647644   UINT16 val;
648645
r20746r20747
661658   return val | (val << 16);
662659}
663660
664static void cps3_decrypt_bios(running_machine &machine)
661void cps3_state::cps3_decrypt_bios()
665662{
666   cps3_state *state = machine.driver_data<cps3_state>();
667663   int i;
668   UINT32 *coderegion = (UINT32*)state->memregion("user1")->base();
664   UINT32 *coderegion = (UINT32*)memregion("user1")->base();
669665
670   state->m_decrypted_bios = (UINT32*)state->memregion("user1")->base();
666   m_decrypted_bios = (UINT32*)memregion("user1")->base();
671667
672668   for (i=0;i<0x80000;i+=4)
673669   {
674670      UINT32 dword = coderegion[i/4];
675      UINT32 xormask = cps3_mask(i, state->m_key1, state->m_key2);
676      state->m_decrypted_bios[i/4] = dword ^ xormask;
671      UINT32 xormask = cps3_mask(i, m_key1, m_key2);
672      m_decrypted_bios[i/4] = dword ^ xormask;
677673   }
678674#if 0
679675   /* Dump to file */
680676   {
681677      FILE *fp;
682      const char *gamename = machine.system().name;
678      const char *gamename = machine().system().name;
683679      char filename[256];
684680      sprintf(filename, "%s_bios.dump", gamename);
685681
686682      fp=fopen(filename, "w+b");
687683      if (fp)
688684      {
689         fwrite(state->m_decrypted_bios, 0x080000, 1, fp);
685         fwrite(m_decrypted_bios, 0x080000, 1, fp);
690686         fclose(fp);
691687      }
692688   }
r20746r20747
694690}
695691
696692
697static void init_common(running_machine &machine, UINT32 key1, UINT32 key2, int altEncryption)
693void cps3_state::init_common(UINT32 key1, UINT32 key2, int altEncryption)
698694{
699   cps3_state *state = machine.driver_data<cps3_state>();
700695
701   state->m_key1 = key1;
702   state->m_key2 = key2;
703   state->m_altEncryption = altEncryption;
696   m_key1 = key1;
697   m_key2 = key2;
698   m_altEncryption = altEncryption;
704699
705700   // cache pointers to regions
706   state->m_user4region = state->memregion("user4")->base();
707   state->m_user5region = state->memregion("user5")->base();
701   m_user4region = memregion("user4")->base();
702   m_user5region = memregion("user5")->base();
708703
709   if (!state->m_user4region) state->m_user4region = auto_alloc_array(machine, UINT8, USER4REGION_LENGTH);
710   if (!state->m_user5region) state->m_user5region = auto_alloc_array(machine, UINT8, USER5REGION_LENGTH);
704   if (!m_user4region) m_user4region = auto_alloc_array(machine(), UINT8, USER4REGION_LENGTH);
705   if (!m_user5region) m_user5region = auto_alloc_array(machine(), UINT8, USER5REGION_LENGTH);
711706
712707   // set strict verify
713   sh2drc_set_options(machine.device("maincpu"), SH2DRC_STRICT_VERIFY);
708   sh2drc_set_options(machine().device("maincpu"), SH2DRC_STRICT_VERIFY);
714709
715   cps3_decrypt_bios(machine);
716   state->m_decrypted_gamerom = auto_alloc_array(machine, UINT32, 0x1000000/4);
710   cps3_decrypt_bios();
711   m_decrypted_gamerom = auto_alloc_array(machine(), UINT32, 0x1000000/4);
717712
718713   /* just some NOPs for the game to execute if it crashes and starts executing unmapped addresses
719714    - this prevents MAME from crashing */
720   state->m_nops = auto_alloc(machine, UINT32);
721   state->m_nops[0] = 0x00090009;
715   m_nops = auto_alloc(machine(), UINT32);
716   m_nops[0] = 0x00090009;
722717
723718
724   state->m_0xc0000000_ram_decrypted = auto_alloc_array(machine, UINT32, 0x400/4);
719   m_0xc0000000_ram_decrypted = auto_alloc_array(machine(), UINT32, 0x400/4);
725720
726   address_space &main = machine.device<sh2_device>("maincpu")->space(AS_PROGRAM);
727   main.set_direct_update_handler(direct_update_delegate(FUNC(cps3_state::cps3_direct_handler), state));
721   address_space &main = machine().device<sh2_device>("maincpu")->space(AS_PROGRAM);
722   main.set_direct_update_handler(direct_update_delegate(FUNC(cps3_state::cps3_direct_handler), this));
728723
729724   // flash roms
730725   astring tempstr;
731726   for (int simmnum = 0; simmnum < 7; simmnum++)
732727      for (int chipnum = 0; chipnum < 8; chipnum++)
733         state->m_simm[simmnum][chipnum] = machine.device<fujitsu_29f016a_device>(tempstr.format("simm%d.%d", simmnum + 1, chipnum));
728         m_simm[simmnum][chipnum] = machine().device<fujitsu_29f016a_device>(tempstr.format("simm%d.%d", simmnum + 1, chipnum));
734729
735   state->m_eeprom = auto_alloc_array(machine, UINT32, 0x400/4);
736   machine.device<nvram_device>("eeprom")->set_base(state->m_eeprom, 0x400);
730   m_eeprom = auto_alloc_array(machine(), UINT32, 0x400/4);
731   machine().device<nvram_device>("eeprom")->set_base(m_eeprom, 0x400);
737732}
738733
739DRIVER_INIT_MEMBER(cps3_state,redearth)  { init_common(machine(), 0x9e300ab1, 0xa175b82c, 0); }
740DRIVER_INIT_MEMBER(cps3_state,sfiii)     { init_common(machine(), 0xb5fe053e, 0xfc03925a, 0); }
741DRIVER_INIT_MEMBER(cps3_state,sfiii2)    { init_common(machine(), 0x00000000, 0x00000000, 1); }
742DRIVER_INIT_MEMBER(cps3_state,jojo)      { init_common(machine(), 0x02203ee3, 0x01301972, 0); }
743DRIVER_INIT_MEMBER(cps3_state,sfiii3)    { init_common(machine(), 0xa55432b4, 0x0c129981, 0); }
744DRIVER_INIT_MEMBER(cps3_state,jojoba)    { init_common(machine(), 0x23323ee3, 0x03021972, 0); }
734DRIVER_INIT_MEMBER(cps3_state,redearth)  { init_common(0x9e300ab1, 0xa175b82c, 0); }
735DRIVER_INIT_MEMBER(cps3_state,sfiii)     { init_common(0xb5fe053e, 0xfc03925a, 0); }
736DRIVER_INIT_MEMBER(cps3_state,sfiii2)    { init_common(0x00000000, 0x00000000, 1); }
737DRIVER_INIT_MEMBER(cps3_state,jojo)      { init_common(0x02203ee3, 0x01301972, 0); }
738DRIVER_INIT_MEMBER(cps3_state,sfiii3)    { init_common(0xa55432b4, 0x0c129981, 0); }
739DRIVER_INIT_MEMBER(cps3_state,jojoba)    { init_common(0x23323ee3, 0x03021972, 0); }
745740
746741
747742
r20746r20747
775770};
776771
777772
778static void cps3_set_mame_colours(running_machine &machine, int colournum, UINT16 data, UINT32 fadeval)
773void cps3_state::cps3_set_mame_colours(int colournum, UINT16 data, UINT32 fadeval)
779774{
780   cps3_state *state = machine.driver_data<cps3_state>();
781775   int r,g,b;
782   UINT16* dst = (UINT16*)state->m_colourram.target();
776   UINT16* dst = (UINT16*)m_colourram.target();
783777
784778
785779   r = (data >> 0) & 0x1f;
r20746r20747
809803
810804   dst[colournum] = data;
811805
812   state->m_mame_colours[colournum] = (r << (16+3)) | (g << (8+3)) | (b << (0+3));
806   m_mame_colours[colournum] = (r << (16+3)) | (g << (8+3)) | (b << (0+3));
813807
814   if (colournum<0x10000) palette_set_color(machine,colournum,state->m_mame_colours[colournum]/* MAKE_RGB(r<<3,g<<3,b<<3)*/);//state->m_mame_colours[colournum]);
808   if (colournum<0x10000) palette_set_color(machine(),colournum,m_mame_colours[colournum]/* MAKE_RGB(r<<3,g<<3,b<<3)*/);//m_mame_colours[colournum]);
815809}
816810
817811
r20746r20747
853847
854848// the 0x400 bit in the tilemap regs is "draw it upside-down"  (bios tilemap during flashing, otherwise capcom logo is flipped)
855849
856static void cps3_draw_tilemapsprite_line(running_machine &machine, int tmnum, int drawline, bitmap_rgb32 &bitmap, const rectangle &cliprect )
850void cps3_state::cps3_draw_tilemapsprite_line(int tmnum, int drawline, bitmap_rgb32 &bitmap, const rectangle &cliprect )
857851{
858   cps3_state *state = machine.driver_data<cps3_state>();
859   UINT32* tmapregs[4] = { state->m_tilemap20_regs_base, state->m_tilemap30_regs_base, state->m_tilemap40_regs_base, state->m_tilemap50_regs_base };
852   UINT32* tmapregs[4] = { m_tilemap20_regs_base, m_tilemap30_regs_base, m_tilemap40_regs_base, m_tilemap50_regs_base };
860853   UINT32* regs;
861854   int line;
862855   int scrolly;
r20746r20747
897890      //  printf("linebase %08x\n", linebase);
898891
899892         scrollx =  (regs[0]&0xffff0000)>>16;
900         scrollx+= (state->m_spriteram[linebase+((line+16-4)&0x3ff)]>>16)&0x3ff;
893         scrollx+= (m_spriteram[linebase+((line+16-4)&0x3ff)]>>16)&0x3ff;
901894
902895      }
903896
r20746r20747
917910         int bpp;
918911         int xflip,yflip;
919912
920         dat = state->m_spriteram[mapbase+((tileline&63)*64)+((x+scrollx/16)&63)];
913         dat = m_spriteram[mapbase+((tileline&63)*64)+((x+scrollx/16)&63)];
921914         tileno = (dat & 0xffff0000)>>17;
922915         colour = (dat & 0x000001ff)>>0;
923916         bpp = (dat & 0x0000200)>>9;
924917         yflip  = (dat & 0x00000800)>>11;
925918         xflip  = (dat & 0x00001000)>>12;
926919
927         if (!bpp) machine.gfx[1]->set_granularity(256);
928         else machine.gfx[1]->set_granularity(64);
920         if (!bpp) machine().gfx[1]->set_granularity(256);
921         else machine().gfx[1]->set_granularity(64);
929922
930         cps3_drawgfxzoom(bitmap,clip,machine.gfx[1],tileno,colour,xflip,yflip,(x*16)-scrollx%16,drawline-tilesubline,CPS3_TRANSPARENCY_PEN_INDEX,0, 0x10000, 0x10000, NULL, 0);
923         cps3_drawgfxzoom(bitmap,clip,machine().gfx[1],tileno,colour,xflip,yflip,(x*16)-scrollx%16,drawline-tilesubline,CPS3_TRANSPARENCY_PEN_INDEX,0, 0x10000, 0x10000, NULL, 0);
931924      }
932925   }
933926}
r20746r20747
10801073               {
10811074                  for (uu=0;uu<1023;uu++)
10821075                  {
1083                     cps3_draw_tilemapsprite_line(machine(), tilemapnum, uu, m_renderbuffer_bitmap, m_renderbuffer_clip );
1076                     cps3_draw_tilemapsprite_line(tilemapnum, uu, m_renderbuffer_bitmap, m_renderbuffer_clip );
10841077                  }
10851078               }
10861079               bg_drawn[tilemapnum] = 1;
r20746r20747
14531446
14541447
14551448
1456static UINT32 cps3_flashmain_r(address_space &space, int which, UINT32 offset, UINT32 mem_mask)
1449UINT32 cps3_state::cps3_flashmain_r(address_space &space, int which, UINT32 offset, UINT32 mem_mask)
14571450{
1458   cps3_state *state = space.machine().driver_data<cps3_state>();
14591451   UINT32 result = 0;
14601452
1461   if (state->m_simm[which][0] == NULL || state->m_simm[which][1] == NULL || state->m_simm[which][2] == NULL || state->m_simm[which][3] == NULL)
1453   if (m_simm[which][0] == NULL || m_simm[which][1] == NULL || m_simm[which][2] == NULL || m_simm[which][3] == NULL)
14621454      return 0xffffffff;
14631455
14641456   if (ACCESSING_BITS_24_31)   // Flash 1
14651457   {
14661458//      logerror("read flash chip %d addr %02x\n", base+0, offset*4 );
1467      result |= (state->m_simm[which][0]->read(offset)<<24);
1459      result |= (m_simm[which][0]->read(offset)<<24);
14681460   }
14691461   if (ACCESSING_BITS_16_23)   // Flash 1
14701462   {
14711463//      logerror("read flash chip %d addr %02x\n", base+1, offset*4 );
1472      result |= (state->m_simm[which][1]->read(offset)<<16);
1464      result |= (m_simm[which][1]->read(offset)<<16);
14731465   }
14741466   if (ACCESSING_BITS_8_15)    // Flash 1
14751467   {
14761468//      logerror("read flash chip %d addr %02x\n", base+2, offset*4 );
1477      result |= (state->m_simm[which][2]->read(offset)<<8);
1469      result |= (m_simm[which][2]->read(offset)<<8);
14781470   }
14791471   if (ACCESSING_BITS_0_7) // Flash 1
14801472   {
14811473//      logerror("read flash chip %d addr %02x\n", base+3, offset*4 );
1482      result |= (state->m_simm[which][3]->read(offset)<<0);
1474      result |= (m_simm[which][3]->read(offset)<<0);
14831475   }
14841476
14851477//  if (base==4) logerror("read flash chips addr %02x returning %08x\n", offset*4, result );
r20746r20747
15091501   return retvalue;
15101502}
15111503
1512static void cps3_flashmain_w(running_machine &machine, int which, UINT32 offset, UINT32 data, UINT32 mem_mask)
1504void cps3_state::cps3_flashmain_w(int which, UINT32 offset, UINT32 data, UINT32 mem_mask)
15131505{
1514   cps3_state *state = machine.driver_data<cps3_state>();
15151506   int command;
15161507
1517   if (state->m_simm[which][0] == NULL || state->m_simm[which][1] == NULL || state->m_simm[which][2] == NULL || state->m_simm[which][3] == NULL)
1508   if (m_simm[which][0] == NULL || m_simm[which][1] == NULL || m_simm[which][2] == NULL || m_simm[which][3] == NULL)
15181509      return;
15191510
15201511   if (ACCESSING_BITS_24_31)   // Flash 1
15211512   {
15221513      command = (data >> 24) & 0xff;
1523      logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][0]->tag(), offset, command);
1524      state->m_simm[which][0]->write(offset, command);
1514      logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][0]->tag(), offset, command);
1515      m_simm[which][0]->write(offset, command);
15251516   }
15261517   if (ACCESSING_BITS_16_23)   // Flash 2
15271518   {
15281519      command = (data >> 16) & 0xff;
1529      logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][1]->tag(), offset, command);
1530      state->m_simm[which][1]->write(offset, command);
1520      logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][1]->tag(), offset, command);
1521      m_simm[which][1]->write(offset, command);
15311522   }
15321523   if (ACCESSING_BITS_8_15)    // Flash 2
15331524   {
15341525      command = (data >> 8) & 0xff;
1535      logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][2]->tag(), offset, command);
1536      state->m_simm[which][2]->write(offset, command);
1526      logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][2]->tag(), offset, command);
1527      m_simm[which][2]->write(offset, command);
15371528   }
15381529   if (ACCESSING_BITS_0_7) // Flash 2
15391530   {
15401531      command = (data >> 0) & 0xff;
1541      logerror("write to flash chip %s addr %02x cmd %02x\n", state->m_simm[which][3]->tag(), offset, command);
1542      state->m_simm[which][3]->write(offset, command);
1532      logerror("write to flash chip %s addr %02x cmd %02x\n", m_simm[which][3]->tag(), offset, command);
1533      m_simm[which][3]->write(offset, command);
15431534   }
15441535
15451536   /* copy data into regions to execute from */
15461537   {
1547      UINT32* romdata =  (UINT32*)state->m_user4region;
1548      UINT32* romdata2 = (UINT32*)state->m_decrypted_gamerom;
1538      UINT32* romdata =  (UINT32*)m_user4region;
1539      UINT32* romdata2 = (UINT32*)m_decrypted_gamerom;
15491540      int real_offset = 0;
15501541      UINT32 newdata;
15511542
r20746r20747
15581549         real_offset += 0x800000;
15591550      }
15601551
1561      newdata = (state->m_simm[which][0]->read_raw(offset)<<24) |
1562               (state->m_simm[which][1]->read_raw(offset)<<16) |
1563               (state->m_simm[which][2]->read_raw(offset)<<8) |
1564               (state->m_simm[which][3]->read_raw(offset)<<0);
1552      newdata = (m_simm[which][0]->read_raw(offset)<<24) |
1553               (m_simm[which][1]->read_raw(offset)<<16) |
1554               (m_simm[which][2]->read_raw(offset)<<8) |
1555               (m_simm[which][3]->read_raw(offset)<<0);
15651556
1566      //printf("%08x %08x %08x %08x %08x\n",offset, romdata2[offset], romdata[offset], newdata,  newdata^cps3_mask(0x6000000+real_offset, state->m_key1, state->m_key2)  );
1557      //printf("%08x %08x %08x %08x %08x\n",offset, romdata2[offset], romdata[offset], newdata,  newdata^cps3_mask(0x6000000+real_offset, m_key1, m_key2)  );
15671558
15681559      romdata[offset] = newdata;
1569      romdata2[offset] = newdata^cps3_mask(0x6000000+real_offset, state->m_key1, state->m_key2);
1560      romdata2[offset] = newdata^cps3_mask(0x6000000+real_offset, m_key1, m_key2);
15701561   }
15711562}
15721563
15731564WRITE32_MEMBER(cps3_state::cps3_flash1_w)
15741565{
1575   cps3_flashmain_w(machine(),0,offset,data,mem_mask);
1566   cps3_flashmain_w(0,offset,data,mem_mask);
15761567}
15771568
15781569WRITE32_MEMBER(cps3_state::cps3_flash2_w)
15791570{
1580   cps3_flashmain_w(machine(),1,offset,data,mem_mask);
1571   cps3_flashmain_w(1,offset,data,mem_mask);
15811572}
15821573
15831574WRITE32_MEMBER(cps3_state::cram_gfxflash_bank_w)
r20746r20747
17781769
17791770               //if (m_paldma_fade!=0) printf("%08x\n",m_paldma_fade);
17801771
1781               cps3_set_mame_colours(machine(), (m_paldma_dest+i)^1, coldata, m_paldma_fade);
1772               cps3_set_mame_colours((m_paldma_dest+i)^1, coldata, m_paldma_fade);
17821773            }
17831774
17841775
r20746r20747
17971788
17981789
17991790
1800static UINT32 process_byte( running_machine &machine, UINT8 real_byte, UINT32 destination, int max_length )
1791UINT32 cps3_state::process_byte( UINT8 real_byte, UINT32 destination, int max_length )
18011792{
1802   cps3_state *state = machine.driver_data<cps3_state>();
1803   UINT8* dest       = (UINT8*)state->m_char_ram;
1793   UINT8* dest       = (UINT8*)m_char_ram;
18041794
18051795   //printf("process byte for destination %08x\n", destination);
18061796
r20746r20747
18111801      int tranfercount = 0;
18121802
18131803      //printf("Set RLE Mode\n");
1814      state->m_rle_length = (real_byte&0x3f)+1;
1804      m_rle_length = (real_byte&0x3f)+1;
18151805
1816      //printf("RLE Operation (length %08x\n", state->m_rle_length );
1806      //printf("RLE Operation (length %08x\n", m_rle_length );
18171807
1818      while (state->m_rle_length)
1808      while (m_rle_length)
18191809      {
1820         dest[((destination+tranfercount)&0x7fffff)^3] = (state->m_last_normal_byte&0x3f);
1821         machine.gfx[1]->mark_dirty(((destination+tranfercount)&0x7fffff)/0x100);
1810         dest[((destination+tranfercount)&0x7fffff)^3] = (m_last_normal_byte&0x3f);
1811         machine().gfx[1]->mark_dirty(((destination+tranfercount)&0x7fffff)/0x100);
18221812         //printf("RLE WRite Byte %08x, %02x\n", destination+tranfercount, real_byte);
18231813
18241814         tranfercount++;
1825         state->m_rle_length--;
1815         m_rle_length--;
18261816         max_length--;
18271817
18281818         if ((destination+tranfercount) > 0x7fffff)  return max_length;
r20746r20747
18361826   {
18371827      //printf("Write Normal Data\n");
18381828      dest[(destination&0x7fffff)^3] = real_byte;
1839      state->m_last_normal_byte = real_byte;
1840      machine.gfx[1]->mark_dirty((destination&0x7fffff)/0x100);
1829      m_last_normal_byte = real_byte;
1830      machine().gfx[1]->mark_dirty((destination&0x7fffff)/0x100);
18411831      return 1;
18421832   }
18431833}
18441834
1845static void cps3_do_char_dma( running_machine &machine, UINT32 real_source, UINT32 real_destination, UINT32 real_length )
1835void cps3_state::cps3_do_char_dma( UINT32 real_source, UINT32 real_destination, UINT32 real_length )
18461836{
1847   cps3_state *state = machine.driver_data<cps3_state>();
1848   UINT8* sourcedata = (UINT8*)state->m_user5region;
1837   UINT8* sourcedata = (UINT8*)m_user5region;
18491838   int length_remaining;
18501839
1851   state->m_last_normal_byte = 0;
1852   state->m_rle_length = 0;
1840   m_last_normal_byte = 0;
1841   m_rle_length = 0;
18531842   length_remaining = real_length;
18541843   while (length_remaining)
18551844   {
r20746r20747
18641853         UINT32 length_processed;
18651854         current_byte &= 0x7f;
18661855
1867         real_byte = sourcedata[DMA_XOR((state->m_current_table_address+current_byte*2+0))];
1856         real_byte = sourcedata[DMA_XOR((m_current_table_address+current_byte*2+0))];
18681857         //if (real_byte&0x80) return;
1869         length_processed = process_byte( machine, real_byte, real_destination, length_remaining );
1858         length_processed = process_byte(real_byte, real_destination, length_remaining );
18701859         length_remaining-=length_processed; // subtract the number of bytes the operation has taken
18711860         real_destination+=length_processed; // add it onto the destination
18721861         if (real_destination>0x7fffff) return;
18731862         if (length_remaining<=0) return; // if we've expired, exit
18741863
1875         real_byte = sourcedata[DMA_XOR((state->m_current_table_address+current_byte*2+1))];
1864         real_byte = sourcedata[DMA_XOR((m_current_table_address+current_byte*2+1))];
18761865         //if (real_byte&0x80) return;
1877         length_processed = process_byte( machine, real_byte, real_destination, length_remaining );
1866         length_processed = process_byte(real_byte, real_destination, length_remaining );
18781867         length_remaining-=length_processed; // subtract the number of bytes the operation has taken
18791868         real_destination+=length_processed; // add it onto the destination
18801869         if (real_destination>0x7fffff) return;
r20746r20747
18831872      else
18841873      {
18851874         UINT32 length_processed;
1886         length_processed = process_byte( machine, current_byte, real_destination, length_remaining );
1875         length_processed = process_byte(current_byte, real_destination, length_remaining );
18871876         length_remaining-=length_processed; // subtract the number of bytes the operation has taken
18881877         real_destination+=length_processed; // add it onto the destination
18891878         if (real_destination>0x7fffff) return;
r20746r20747
18941883   }
18951884}
18961885
1897static UINT32 ProcessByte8(running_machine &machine,UINT8 b,UINT32 dst_offset)
1886UINT32 cps3_state::ProcessByte8(UINT8 b,UINT32 dst_offset)
18981887{
1899   cps3_state *state = machine.driver_data<cps3_state>();
1900   UINT8* destRAM = (UINT8*)state->m_char_ram;
1888   UINT8* destRAM = (UINT8*)m_char_ram;
19011889   int l=0;
19021890
1903   if(state->m_lastb==state->m_lastb2) //rle
1891   if(m_lastb==m_lastb2) //rle
19041892   {
19051893      int i;
19061894      int rle=(b+1)&0xff;
19071895
19081896      for(i=0;i<rle;++i)
19091897      {
1910         destRAM[(dst_offset&0x7fffff)^3] = state->m_lastb;
1911         machine.gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100);
1898         destRAM[(dst_offset&0x7fffff)^3] = m_lastb;
1899         machine().gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100);
19121900
19131901         dst_offset++;
19141902         ++l;
19151903      }
1916      state->m_lastb2=0xffff;
1904      m_lastb2=0xffff;
19171905
19181906      return l;
19191907   }
19201908   else
19211909   {
1922      state->m_lastb2=state->m_lastb;
1923      state->m_lastb=b;
1910      m_lastb2=m_lastb;
1911      m_lastb=b;
19241912      destRAM[(dst_offset&0x7fffff)^3] = b;
1925      machine.gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100);
1913      machine().gfx[1]->mark_dirty((dst_offset&0x7fffff)/0x100);
19261914      return 1;
19271915   }
19281916}
19291917
1930static void cps3_do_alt_char_dma( running_machine &machine, UINT32 src, UINT32 real_dest, UINT32 real_length )
1918void cps3_state::cps3_do_alt_char_dma( UINT32 src, UINT32 real_dest, UINT32 real_length )
19311919{
1932   cps3_state *state = machine.driver_data<cps3_state>();
1933   UINT8* px = (UINT8*)state->m_user5region;
1920   UINT8* px = (UINT8*)m_user5region;
19341921   UINT32 start = real_dest;
19351922   UINT32 ds = real_dest;
19361923
1937   state->m_lastb=0xfffe;
1938   state->m_lastb2=0xffff;
1924   m_lastb=0xfffe;
1925   m_lastb2=0xffff;
19391926
19401927   while(1)
19411928   {
r20746r20747
19511938         {
19521939            UINT8 real_byte;
19531940            p&=0x7f;
1954            real_byte = px[DMA_XOR((state->m_current_table_address+p*2+0))];
1955            ds+=ProcessByte8(machine,real_byte,ds);
1956            real_byte = px[DMA_XOR((state->m_current_table_address+p*2+1))];
1957            ds+=ProcessByte8(machine,real_byte,ds);
1941            real_byte = px[DMA_XOR((m_current_table_address+p*2+0))];
1942            ds+=ProcessByte8(real_byte,ds);
1943            real_byte = px[DMA_XOR((m_current_table_address+p*2+1))];
1944            ds+=ProcessByte8(real_byte,ds);
19581945         }
19591946         else
19601947         {
1961            ds+=ProcessByte8(machine,p,ds);
1948            ds+=ProcessByte8(p,ds);
19621949         }
19631950         ++src;
19641951         ctrl<<=1;
r20746r20747
19691956   }
19701957}
19711958
1972static void cps3_process_character_dma(running_machine &machine, UINT32 address)
1959void cps3_state::cps3_process_character_dma(UINT32 address)
19731960{
1974   cps3_state *state = machine.driver_data<cps3_state>();
19751961   int i;
19761962
19771963   //printf("charDMA start:\n");
19781964
19791965   for (i = 0; i < 0x1000; i += 3)
19801966   {
1981      UINT32 dat1 = LITTLE_ENDIANIZE_INT32(state->m_char_ram[i + 0 + (address)]);
1982      UINT32 dat2 = LITTLE_ENDIANIZE_INT32(state->m_char_ram[i + 1 + (address)]);
1983      UINT32 dat3 = LITTLE_ENDIANIZE_INT32(state->m_char_ram[i + 2 + (address)]);
1967      UINT32 dat1 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 0 + (address)]);
1968      UINT32 dat2 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 1 + (address)]);
1969      UINT32 dat3 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 2 + (address)]);
19841970      UINT32 real_source      = (dat3 << 1) - 0x400000;
19851971      UINT32 real_destination =  dat2 << 3;
19861972      UINT32 real_length      = (((dat1 & 0x001fffff) + 1) << 3);
r20746r20747
19951981         /* Sets a table used by the decompression routines */
19961982         {
19971983            /* We should probably copy this, but a pointer to it is fine for our purposes as the data doesn't change */
1998            state->m_current_table_address = real_source;
1984            m_current_table_address = real_source;
19991985         }
2000         machine.device("maincpu")->execute().set_input_line(10, ASSERT_LINE);
1986         machine().device("maincpu")->execute().set_input_line(10, ASSERT_LINE);
20011987      }
20021988      else if  ((dat1 & 0x00e00000) == 0x00400000)
20031989      {
20041990         /* 6bpp DMA decompression
20051991           - this is used for the majority of sprites and backgrounds */
2006         cps3_do_char_dma( machine, real_source, real_destination, real_length );
2007         machine.device("maincpu")->execute().set_input_line(10, ASSERT_LINE);
1992         cps3_do_char_dma(real_source, real_destination, real_length );
1993         machine().device("maincpu")->execute().set_input_line(10, ASSERT_LINE);
20081994
20091995      }
20101996      else if  ((dat1 & 0x00e00000) == 0x00600000)
20111997      {
20121998         /* 8bpp DMA decompression
20131999           - this is used on SFIII NG Sean's Stage ONLY */
2014         cps3_do_alt_char_dma( machine, real_source, real_destination, real_length);
2015         machine.device("maincpu")->execute().set_input_line(10, ASSERT_LINE);
2000         cps3_do_alt_char_dma(real_source, real_destination, real_length);
2001         machine().device("maincpu")->execute().set_input_line(10, ASSERT_LINE);
20162002      }
20172003      else
20182004      {
r20746r20747
20512037            list_address = (m_chardma_source | ((m_chardma_other&0x003f0000)));
20522038
20532039            //printf("chardma_w activated %08x %08x (address = cram %08x)\n", m_chardma_source, m_chardma_other, list_address*4 );
2054            cps3_process_character_dma(machine(), list_address);
2040            cps3_process_character_dma(list_address);
20552041         }
20562042         else
20572043         {
r20746r20747
20962082
20972083   if (ACCESSING_BITS_24_31)
20982084   {
2099      cps3_set_mame_colours(machine(), offset*2, (data & 0xffff0000) >> 16, 0);
2085      cps3_set_mame_colours(offset*2, (data & 0xffff0000) >> 16, 0);
21002086   }
21012087
21022088   if (ACCESSING_BITS_0_7)
21032089   {
2104      cps3_set_mame_colours(machine(), offset*2+1, (data & 0x0000ffff) >> 0, 0);
2090      cps3_set_mame_colours(offset*2+1, (data & 0x0000ffff) >> 0, 0);
21052091   }
21062092}
21072093
r20746r20747
22682254   m_current_table_address = -1;
22692255
22702256   // copy data from flashroms back into user regions + decrypt into regions we execute/draw from.
2271   copy_from_nvram(machine());
2257   copy_from_nvram();
22722258}
22732259
22742260
22752261
22762262// make a copy in the regions we execute code / draw gfx from
2277static void copy_from_nvram(running_machine &machine)
2263void cps3_state::copy_from_nvram()
22782264{
2279   cps3_state *state = machine.driver_data<cps3_state>();
2280   UINT32* romdata = (UINT32*)state->m_user4region;
2281   UINT32* romdata2 = (UINT32*)state->m_decrypted_gamerom;
2265   UINT32* romdata = (UINT32*)m_user4region;
2266   UINT32* romdata2 = (UINT32*)m_decrypted_gamerom;
22822267   int i;
22832268   /* copy + decrypt program roms which have been loaded from flashroms/nvram */
22842269   for (i=0;i<0x800000;i+=4)
22852270   {
22862271      UINT32 data;
22872272
2288      data = ((state->m_simm[0][0]->read_raw(i/4)<<24) | (state->m_simm[0][1]->read_raw(i/4)<<16) | (state->m_simm[0][2]->read_raw(i/4)<<8) | (state->m_simm[0][3]->read_raw(i/4)<<0));
2273      data = ((m_simm[0][0]->read_raw(i/4)<<24) | (m_simm[0][1]->read_raw(i/4)<<16) | (m_simm[0][2]->read_raw(i/4)<<8) | (m_simm[0][3]->read_raw(i/4)<<0));
22892274
2290   //  printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6000000, state->m_key1, state->m_key2));
2275   //  printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6000000, m_key1, m_key2));
22912276      romdata[i/4] = data;
2292      romdata2[i/4] = data ^ cps3_mask(i+0x6000000, state->m_key1, state->m_key2);
2277      romdata2[i/4] = data ^ cps3_mask(i+0x6000000, m_key1, m_key2);
22932278
22942279   }
22952280
22962281   romdata  += 0x800000/4;
22972282   romdata2 += 0x800000/4;
22982283
2299   if (state->m_simm[1][0] != NULL)
2284   if (m_simm[1][0] != NULL)
23002285      for (i=0;i<0x800000;i+=4)
23012286      {
23022287         UINT32 data;
23032288
2304         data = ((state->m_simm[1][0]->read_raw(i/4)<<24) | (state->m_simm[1][1]->read_raw(i/4)<<16) | (state->m_simm[1][2]->read_raw(i/4)<<8) | (state->m_simm[1][3]->read_raw(i/4)<<0));
2289         data = ((m_simm[1][0]->read_raw(i/4)<<24) | (m_simm[1][1]->read_raw(i/4)<<16) | (m_simm[1][2]->read_raw(i/4)<<8) | (m_simm[1][3]->read_raw(i/4)<<0));
23052290
2306      //  printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4],  data ^ cps3_mask(i+0x6800000, state->m_key1, state->m_key2) );
2291      //  printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4],  data ^ cps3_mask(i+0x6800000, m_key1, m_key2) );
23072292         romdata[i/4] = data;
2308         romdata2[i/4] = data ^ cps3_mask(i+0x6800000, state->m_key1, state->m_key2);
2293         romdata2[i/4] = data ^ cps3_mask(i+0x6800000, m_key1, m_key2);
23092294      }
23102295
23112296   /* copy gfx from loaded flashroms to user reigon 5, where it's used */
r20746r20747
23142299      int flashnum = 0;
23152300      int countoffset = 0;
23162301
2317      romdata = (UINT32*)state->m_user5region;
2302      romdata = (UINT32*)m_user5region;
23182303      for (thebase = 0;thebase < len/2; thebase+=0x200000)
23192304      {
23202305      //  printf("flashnums %d. %d\n",flashnum, flashnum+1);
23212306
2322         fujitsu_29f016a_device *flash0 = state->m_simm[2 + flashnum/8][flashnum % 8 + 0];
2323         fujitsu_29f016a_device *flash1 = state->m_simm[2 + flashnum/8][flashnum % 8 + 1];
2307         fujitsu_29f016a_device *flash0 = m_simm[2 + flashnum/8][flashnum % 8 + 0];
2308         fujitsu_29f016a_device *flash1 = m_simm[2 + flashnum/8][flashnum % 8 + 1];
23242309         if (flash0 == NULL || flash1 == NULL)
23252310            continue;
23262311         if (flash0 != NULL && flash1 != NULL)
r20746r20747
23462331   /*
23472332   {
23482333       FILE *fp;
2349       const char *gamename = machine.system().name;
2334       const char *gamename = machine().system().name;
23502335       char filename[256];
23512336       sprintf(filename, "%s_bios.dump", gamename);
23522337
r20746r20747
23872372   if (src<0x80000)
23882373   {
23892374      int offs = (src&0x07ffff)>>2;
2390      data = data ^ cps3_mask(offs*4, state->m_key1, state->m_key2);
2375      data = data ^ state->cps3_mask(offs*4, state->m_key1, state->m_key2);
23912376   }
23922377   else if (src>=0x6000000 && src<0x6800000)
23932378   {
23942379      int offs = (src&0x07fffff)>>2;
2395      if (!state->m_altEncryption) data = data ^ cps3_mask(0x6000000+offs*4, state->m_key1, state->m_key2);
2380      if (!state->m_altEncryption) data = data ^ state->cps3_mask(0x6000000+offs*4, state->m_key1, state->m_key2);
23962381   }
23972382   else if (src>=0x6800000 && src<0x7000000)
23982383   {
23992384      int offs = (src&0x07fffff)>>2;
2400      if (!state->m_altEncryption) data = data ^ cps3_mask(0x6800000+offs*4, state->m_key1, state->m_key2);
2385      if (!state->m_altEncryption) data = data ^ state->cps3_mask(0x6800000+offs*4, state->m_key1, state->m_key2);
24012386   }
24022387   else
24032388   {
trunk/src/mame/drivers/cloud9.c
r20746r20747
110110 *
111111 *************************************/
112112
113INLINE void schedule_next_irq(running_machine &machine, int curscanline)
113inline void cloud9_state::schedule_next_irq(int curscanline)
114114{
115   cloud9_state *state = machine.driver_data<cloud9_state>();
116115
117116   /* IRQ is clocked by /32V, so every 64 scanlines */
118117   curscanline = (curscanline + 64) & 255;
119118
120119   /* next one at the start of this scanline */
121   state->m_irq_timer->adjust(machine.primary_screen->time_until_pos(curscanline), curscanline);
120   m_irq_timer->adjust(machine().primary_screen->time_until_pos(curscanline), curscanline);
122121}
123122
124123
r20746r20747
135134   machine().primary_screen->update_partial(machine().primary_screen->vpos());
136135
137136   /* find the next edge */
138   schedule_next_irq(machine(), param);
137   schedule_next_irq(param);
139138}
140139
141140
r20746r20747
182181   /* create a timer for IRQs and set up the first callback */
183182   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cloud9_state::clock_irq),this));
184183   m_irq_state = 0;
185   schedule_next_irq(machine(), 0-64);
184   schedule_next_irq(0-64);
186185
187186   /* setup for save states */
188187   save_item(NAME(m_irq_state));
trunk/src/mame/drivers/crshrace.c
r20746r20747
570570
571571
572572#ifdef UNUSED_FUNCTION
573void crshrace_patch_code( UINT16 offset )
573void crshrace_state::crshrace_patch_code( UINT16 offset )
574574{
575575   /* A hack which shows 3 player mode in code which is disabled */
576   UINT16 *RAM = (UINT16 *)machine.root_device().memregion("maincpu")->base();
576   UINT16 *RAM = (UINT16 *)machine().root_device().memregion("maincpu")->base();
577577   RAM[(offset + 0)/2] = 0x4e71;
578578   RAM[(offset + 2)/2] = 0x4e71;
579579   RAM[(offset + 4)/2] = 0x4e71;
trunk/src/mame/drivers/crospang.c
r20746r20747
553553ROM_END
554554
555555
556static void tumblepb_gfx1_rearrange(running_machine &machine)
556void crospang_state::tumblepb_gfx1_rearrange()
557557{
558   UINT8 *rom = machine.root_device().memregion("gfx1")->base();
559   int len = machine.root_device().memregion("gfx1")->bytes();
558   UINT8 *rom = machine().root_device().memregion("gfx1")->base();
559   int len = machine().root_device().memregion("gfx1")->bytes();
560560   int i;
561561
562562   /* gfx data is in the wrong order */
r20746r20747
576576
577577DRIVER_INIT_MEMBER(crospang_state,crospang)
578578{
579   tumblepb_gfx1_rearrange(machine());
579   tumblepb_gfx1_rearrange();
580580}
581581
582582GAME( 1998, crospang, 0, crospang, crospang, crospang_state, crospang, ROT0, "F2 System", "Cross Pang", GAME_SUPPORTS_SAVE )
trunk/src/mame/drivers/galaxia.c
r20746r20747
7070INTERRUPT_GEN_MEMBER(galaxia_state::galaxia_interrupt)
7171{
7272   device.execute().set_input_line_and_vector(0, HOLD_LINE, 0x03);
73   cvs_scroll_stars(machine());
73   cvs_scroll_stars();
7474}
7575
7676
trunk/src/mame/drivers/ccastles.c
r20746r20747
138138 *
139139 *************************************/
140140
141INLINE void schedule_next_irq( running_machine &machine, int curscanline )
141inline void ccastles_state::schedule_next_irq( int curscanline )
142142{
143   ccastles_state *state = machine.driver_data<ccastles_state>();
144143
145144   /* scan for a rising edge on the IRQCK signal */
146145   for (curscanline++; ; curscanline = (curscanline + 1) & 0xff)
147      if ((state->m_syncprom[(curscanline - 1) & 0xff] & 8) == 0 && (state->m_syncprom[curscanline] & 8) != 0)
146      if ((m_syncprom[(curscanline - 1) & 0xff] & 8) == 0 && (m_syncprom[curscanline] & 8) != 0)
148147         break;
149148
150149   /* next one at the start of this scanline */
151   state->m_irq_timer->adjust(machine.primary_screen->time_until_pos(curscanline), curscanline);
150   m_irq_timer->adjust(machine().primary_screen->time_until_pos(curscanline), curscanline);
152151}
153152
154153
r20746r20747
165164   machine().primary_screen->update_partial(machine().primary_screen->vpos());
166165
167166   /* find the next edge */
168   schedule_next_irq(machine(), param);
167   schedule_next_irq(param);
169168}
170169
171170
r20746r20747
215214   /* create a timer for IRQs and set up the first callback */
216215   m_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ccastles_state::clock_irq),this));
217216   m_irq_state = 0;
218   schedule_next_irq(machine(), 0);
217   schedule_next_irq(0);
219218
220219   /* setup for save states */
221220   save_item(NAME(m_irq_state));
trunk/src/mame/drivers/cabal.c
r20746r20747
832832
833833
834834
835static void seibu_sound_bootleg(running_machine &machine,const char *cpu,int length)
835void cabal_state::seibu_sound_bootleg(const char *cpu,int length)
836836{
837   address_space &space = machine.device(cpu)->memory().space(AS_PROGRAM);
838   UINT8 *decrypt = auto_alloc_array(machine, UINT8, length);
839   UINT8 *rom = machine.root_device().memregion(cpu)->base();
837   address_space &space = machine().device(cpu)->memory().space(AS_PROGRAM);
838   UINT8 *decrypt = auto_alloc_array(machine(), UINT8, length);
839   UINT8 *rom = machine().root_device().memregion(cpu)->base();
840840
841841   space.set_decrypted_region(0x0000, (length < 0x10000) ? (length - 1) : 0x1fff, decrypt);
842842
843843   memcpy(decrypt, rom+length, length);
844844
845845   if (length > 0x10000)
846      machine.root_device().membank("bank1")->configure_decrypted_entries(0, (length - 0x10000) / 0x8000, decrypt + 0x10000, 0x8000);
846      machine().root_device().membank("bank1")->configure_decrypted_entries(0, (length - 0x10000) / 0x8000, decrypt + 0x10000, 0x8000);
847847}
848848
849849
r20746r20747
857857
858858DRIVER_INIT_MEMBER(cabal_state,cabalbl2)
859859{
860   seibu_sound_bootleg(machine(),"audiocpu",0x2000);
860   seibu_sound_bootleg("audiocpu",0x2000);
861861   seibu_adpcm_decrypt(machine(),"adpcm1");
862862   seibu_adpcm_decrypt(machine(),"adpcm2");
863863}
trunk/src/mame/drivers/compgolf.c
r20746r20747
333333 *
334334 *************************************/
335335
336static void compgolf_expand_bg(running_machine &machine)
336void compgolf_state::compgolf_expand_bg()
337337{
338   UINT8 *GFXDST = machine.root_device().memregion("gfx2")->base();
339   UINT8 *GFXSRC = machine.root_device().memregion("gfx4")->base();
338   UINT8 *GFXDST = machine().root_device().memregion("gfx2")->base();
339   UINT8 *GFXSRC = machine().root_device().memregion("gfx4")->base();
340340
341341   int x;
342342
r20746r20747
350350DRIVER_INIT_MEMBER(compgolf_state,compgolf)
351351{
352352   machine().root_device().membank("bank1")->configure_entries(0, 2, machine().root_device().memregion("user1")->base(), 0x4000);
353   compgolf_expand_bg(machine());
353   compgolf_expand_bg();
354354}
355355
356356
trunk/src/mame/drivers/cdi.c
r20746r20747
3535#include "imagedev/chd_cd.h"
3636
3737#if ENABLE_VERBOSE_LOG
38INLINE void verboselog(running_machine &machine, int n_level, const char *s_fmt, ...)
38INLINE ::void verboselog(int n_level, const char *s_fmt, ...)
3939{
4040   if( VERBOSE_LEVEL >= n_level )
4141   {
r20746r20747
4444      va_start( v, s_fmt );
4545      vsprintf( buf, s_fmt, v );
4646      va_end( v );
47      logerror( "%08x: %s", machine.device("maincpu")->safe_pc(), buf );
47      logerror( "%08x: %s", machine().device("maincpu")->safe_pc(), buf );
4848   }
4949}
5050#else
trunk/src/mame/drivers/crbaloon.c
r20746r20747
4444#define LOG_PC3092      0
4545
4646
47static void pc3092_reset(void)
47void crbaloon_state::pc3092_reset(void)
4848{
4949   /* nothing yet */
5050}
5151
5252
53static void pc3092_update(running_machine &machine)
53void crbaloon_state::pc3092_update()
5454{
55   crbaloon_state *state = machine.driver_data<crbaloon_state>();
56   state->flip_screen_set((state->m_pc3092_data[1] & 0x01) ? TRUE : FALSE);
55   flip_screen_set((m_pc3092_data[1] & 0x01) ? TRUE : FALSE);
5756}
5857
5958
r20746r20747
6362
6463   if (LOG_PC3092) logerror("%04X:  write PC3092 #%d = 0x%02x\n", space.device().safe_pc(), offset, m_pc3092_data[offset]);
6564
66   pc3092_update(machine());
65   pc3092_update();
6766}
6867
6968
r20746r20747
107106#define LOG_PC3259      0
108107
109108
110static void pc3259_update(void)
109void crbaloon_state::pc3259_update(void)
111110{
112111   /* nothing yet */
113112}
r20746r20747
118117   UINT8 ret = 0;
119118   UINT8 reg = offset >> 2;
120119
121   UINT16 collision_address = crbaloon_get_collision_address(machine());
120   UINT16 collision_address = crbaloon_get_collision_address();
122121   int collided = (collision_address != 0xffff);
123122
124123   switch (reg)
r20746r20747
160159
161160   /* D0 - interrupt enable - also goes to PC3259 as /HTCTRL */
162161   m_irq_mask = data & 0x01;
163   crbaloon_set_clear_collision_address(machine(), (data & 0x01) ? TRUE : FALSE);
162   crbaloon_set_clear_collision_address((data & 0x01) ? TRUE : FALSE);
164163
165164   /* D1 - SOUND STOP */
166165   machine().sound().system_enable((data & 0x02) ? TRUE : FALSE);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team