Previous 199869 Revisions Next

r20831 Friday 8th February, 2013 at 13:40:47 UTC by Miodrag Milanović
Modernization of drivers part 10 (no whatsnew)
[src/mame/drivers]kaneko16.c karnov.c kchamp.c kickgoal.c
[src/mame/includes]kaneko16.h kangaroo.h karnov.h kchamp.h kickgoal.h kingobox.h kncljoe.h ksayakyu.h kyugo.h
[src/mame/video]kaneko16.c kangaroo.c karnov.c kchamp.c kickgoal.c kingobox.c kncljoe.c ksayakyu.c kyugo.c

trunk/src/mame/includes/karnov.h
r20830r20831
5959   DECLARE_VIDEO_START(wndrplnt);
6060   UINT32 screen_update_karnov(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6161   INTERRUPT_GEN_MEMBER(karnov_interrupt);
62   void karnov_flipscreen_w( int data );
63   void draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect );
64   void karnov_i8751_w( int data );
65   void wndrplnt_i8751_w( int data );
66   void chelnov_i8751_w( int data );
6267};
6368
6469enum {
trunk/src/mame/includes/kingobox.h
r20830r20831
5959   UINT32 screen_update_kingofb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6060   UINT32 screen_update_ringking(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6161   INTERRUPT_GEN_MEMBER(kingofb_interrupt);
62   void palette_init_common( const UINT8 *color_prom, void (kingofb_state::*get_rgb_data)(const UINT8 *, int, int *, int *, int *) );
63   void kingofb_get_rgb_data( const UINT8 *color_prom, int i, int *r_data, int *g_data, int *b_data );
64   void ringking_get_rgb_data( const UINT8 *color_prom, int i, int *r_data, int *g_data, int *b_data );
65   void kingofb_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
66   void ringking_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
6267};
trunk/src/mame/includes/kangaroo.h
r20830r20831
3131   virtual void video_start();
3232   DECLARE_MACHINE_START(kangaroo_mcu);
3333   UINT32 screen_update_kangaroo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
34   void videoram_write( UINT16 offset, UINT8 data, UINT8 mask );
35   void blitter_execute(  );
3436};
trunk/src/mame/includes/kchamp.h
r20830r20831
5252   UINT32 screen_update_kchamp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5353   INTERRUPT_GEN_MEMBER(kc_interrupt);
5454   INTERRUPT_GEN_MEMBER(sound_int);
55   void kchamp_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
56   void kchampvs_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
57   UINT8 *decrypt_code();
5558};
trunk/src/mame/includes/kaneko16.h
r20830r20831
6767   UINT32 screen_update_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6868   TIMER_DEVICE_CALLBACK_MEMBER(kaneko16_interrupt);
6969   TIMER_DEVICE_CALLBACK_MEMBER(shogwarr_interrupt);
70   void kaneko16_fill_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);
71   void kaneko16_common_oki_bank_w(  const char *bankname, const char* tag, int bank, size_t fixedsize, size_t bankedsize );
72   void kaneko16_unscramble_tiles(const char *region);
73   void kaneko16_expand_sample_banks(const char *region);
7074};
7175
7276class kaneko16_gtmr_state : public kaneko16_state
r20830r20831
117121   DECLARE_PALETTE_INIT(berlwall);
118122   DECLARE_VIDEO_START(berlwall);
119123   UINT32 screen_update_berlwall(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
124   void kaneko16_render_15bpp_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);
120125};
121126
122127class kaneko16_shogwarr_state : public kaneko16_state
trunk/src/mame/includes/kncljoe.h
r20830r20831
4747   virtual void palette_init();
4848   UINT32 screen_update_kncljoe(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4949   INTERRUPT_GEN_MEMBER(sound_nmi);
50   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5051};
trunk/src/mame/includes/kickgoal.h
r20830r20831
7676   DECLARE_VIDEO_START(actionhw);
7777   UINT32 screen_update_kickgoal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7878   INTERRUPT_GEN_MEMBER(kickgoal_interrupt);
79   void kickgoal_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
80   void kickgoal_play(okim6295_device *oki, int melody, int data);
7981};
trunk/src/mame/includes/kyugo.h
r20830r20831
6060   virtual void video_start();
6161   UINT32 screen_update_kyugo(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/ksayakyu.h
r20830r20831
4040   virtual void video_start();
4141   virtual void palette_init();
4242   UINT32 screen_update_ksayakyu(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
43   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
4344};
trunk/src/mame/video/kchamp.c
r20830r20831
6565             3        XXXXXXXX
6666*/
6767
68static void kchamp_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
68void kchamp_state::kchamp_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
6969{
70   kchamp_state *state = machine.driver_data<kchamp_state>();
71   UINT8 *spriteram = state->m_spriteram;
70   UINT8 *spriteram = m_spriteram;
7271   int offs;
7372
7473   for (offs = 0; offs < 0x100; offs += 4)
r20830r20831
8281      int sx = spriteram[offs + 3] - 8;
8382      int sy = 247 - spriteram[offs];
8483
85      if (state->flip_screen())
84      if (flip_screen())
8685      {
8786         sx = 240 - sx;
8887         sy = 240 - sy;
r20830r20831
9089         flipy = !flipy;
9190      }
9291
93      drawgfx_transpen(bitmap, cliprect, machine.gfx[bank], code, color, flipx, flipy, sx, sy, 0);
92      drawgfx_transpen(bitmap, cliprect, machine().gfx[bank], code, color, flipx, flipy, sx, sy, 0);
9493   }
9594}
9695
97static void kchampvs_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
96void kchamp_state::kchampvs_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
9897{
99   kchamp_state *state = machine.driver_data<kchamp_state>();
100   UINT8 *spriteram = state->m_spriteram;
98   UINT8 *spriteram = m_spriteram;
10199   int offs;
102100
103101   for (offs = 0; offs < 0x100; offs += 4)
r20830r20831
111109      int sx = spriteram[offs + 3];
112110      int sy = 240 - spriteram[offs];
113111
114      if (state->flip_screen())
112      if (flip_screen())
115113      {
116114         sx = 240 - sx;
117115         sy = 240 - sy;
r20830r20831
119117         flipy = !flipy;
120118      }
121119
122      drawgfx_transpen(bitmap, cliprect, machine.gfx[bank], code, color, flipx, flipy, sx, sy, 0);
120      drawgfx_transpen(bitmap, cliprect, machine().gfx[bank], code, color, flipx, flipy, sx, sy, 0);
123121   }
124122}
125123
r20830r20831
127125UINT32 kchamp_state::screen_update_kchamp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
128126{
129127   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
130   kchamp_draw_sprites(machine(), bitmap, cliprect);
128   kchamp_draw_sprites(bitmap, cliprect);
131129   return 0;
132130}
133131
134132UINT32 kchamp_state::screen_update_kchampvs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
135133{
136134   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
137   kchampvs_draw_sprites(machine(), bitmap, cliprect);
135   kchampvs_draw_sprites(bitmap, cliprect);
138136   return 0;
139137}
trunk/src/mame/video/kaneko16.c
r20830r20831
2424
2525
2626
27static void kaneko16_fill_bitmap(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
27void kaneko16_state::kaneko16_fill_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect)
2828{
29   kaneko16_state *state = machine.driver_data<kaneko16_state>();
30   if (state->m_kaneko_spr)
31      if(state->m_kaneko_spr->get_sprite_type()== 1)
29   if (m_kaneko_spr)
30      if(m_kaneko_spr->get_sprite_type()== 1)
3231      {
3332         bitmap.fill(0x7f00, cliprect);
3433         return;
r20830r20831
6766
6867UINT32 kaneko16_state::screen_update_kaneko16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
6968{
70   kaneko16_fill_bitmap(machine(),bitmap,cliprect);
69   kaneko16_fill_bitmap(bitmap,cliprect);
7170
7271   // if the display is disabled, do nothing?
7372   if (!m_disp_enable) return 0;
r20830r20831
168167}
169168
170169
171static void kaneko16_render_15bpp_bitmap(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
170void kaneko16_berlwall_state::kaneko16_render_15bpp_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect)
172171{
173   kaneko16_berlwall_state *state = machine.driver_data<kaneko16_berlwall_state>();
174   if (state->m_bg15_bitmap.valid())
172   if (m_bg15_bitmap.valid())
175173   {
176      int select  =   state->m_bg15_select[ 0 ];
177//      int reg     =   state->m_bg15_reg[ 0 ];
174      int select  =   m_bg15_select[ 0 ];
175//      int reg     =   m_bg15_reg[ 0 ];
178176      int flip    =   select & 0x20;
179177      int sx, sy;
180178
r20830r20831
183181      sx      =   (select & 0x1f) * 256;
184182      sy      =   0;
185183
186      copybitmap(bitmap, state->m_bg15_bitmap, flip, flip, -sx, -sy, cliprect);
184      copybitmap(bitmap, m_bg15_bitmap, flip, flip, -sx, -sy, cliprect);
187185
188186//      flag = 0;
189187   }
r20830r20831
191189UINT32 kaneko16_berlwall_state::screen_update_berlwall(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
192190{
193191   // berlwall uses a 15bpp bitmap as a bg, not a solid fill
194   kaneko16_render_15bpp_bitmap(machine(),bitmap,cliprect);
192   kaneko16_render_15bpp_bitmap(bitmap,cliprect);
195193
196194   // if the display is disabled, do nothing?
197195   if (!m_disp_enable) return 0;
trunk/src/mame/video/kickgoal.c
r20830r20831
8888
8989
9090
91static void kickgoal_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
91void kickgoal_state::kickgoal_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
9292{
93   kickgoal_state *state = machine.driver_data<kickgoal_state>();
94   UINT16 *spriteram = state->m_spriteram;
95   gfx_element *gfx = machine.gfx[1];
93   UINT16 *spriteram = m_spriteram;
94   gfx_element *gfx = machine().gfx[1];
9695   int offs;
9796
98   for (offs = 0; offs < state->m_spriteram.bytes() / 2; offs += 4)
97   for (offs = 0; offs < m_spriteram.bytes() / 2; offs += 4)
9998   {
10099      int xpos = spriteram[offs + 3];
101100      int ypos = spriteram[offs + 0] & 0x00ff;
r20830r20831
108107      ypos = 0x110 - ypos;
109108
110109      drawgfx_transpen(bitmap,cliprect,gfx,
111            tileno+state->m_sprbase,
110            tileno+m_sprbase,
112111            0x30 + color,
113112            flipx,0,
114113            xpos-16+4,ypos-32,15);
r20830r20831
172171   m_bg2tm->draw(bitmap, cliprect, 0, 0);
173172   m_bgtm->draw(bitmap, cliprect, 0, 0);
174173
175   kickgoal_draw_sprites(machine(), bitmap, cliprect);
174   kickgoal_draw_sprites(bitmap, cliprect);
176175
177176   m_fgtm->draw(bitmap, cliprect, 0, 0);
178177
trunk/src/mame/video/ksayakyu.c
r20830r20831
7878[3]
7979*/
8080
81static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
81void ksayakyu_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
8282{
83   ksayakyu_state *state = machine.driver_data<ksayakyu_state>();
84   const UINT8 *source = state->m_spriteram + state->m_spriteram.bytes() - 4;
85   const UINT8 *finish = state->m_spriteram;
83   const UINT8 *source = m_spriteram + m_spriteram.bytes() - 4;
84   const UINT8 *finish = m_spriteram;
8685
8786   while (source>=finish) /* is order correct ? */
8887   {
r20830r20831
9392      int flipx = (tile & 0x80) ? 1 : 0;
9493      int flipy = 0;
9594
96      gfx_element *gfx = machine.gfx[2];
95      gfx_element *gfx = machine().gfx[2];
9796
98      if (state->m_flipscreen)
97      if (m_flipscreen)
9998      {
10099         sx = 240 - sx;
101100         sy = 240 - sy;
r20830r20831
128127      m_tilemap->draw(bitmap, cliprect, 0, 0);
129128
130129   m_textmap->draw(bitmap, cliprect, 0, 0);
131   draw_sprites(machine(), bitmap, cliprect);
130   draw_sprites(bitmap, cliprect);
132131   return 0;
133132}
trunk/src/mame/video/karnov.c
r20830r20831
6666   }
6767}
6868
69void karnov_flipscreen_w( running_machine &machine, int data )
69void karnov_state::karnov_flipscreen_w( int data )
7070{
71   karnov_state *state = machine.driver_data<karnov_state>();
72   state->m_flipscreen = data;
73   machine.tilemap().set_flip_all(state->m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
74   state->flip_screen_set(state->m_flipscreen);
71   m_flipscreen = data;
72   machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
73   flip_screen_set(m_flipscreen);
7574}
7675
77static void draw_background( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
76void karnov_state::draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect )
7877{
79   karnov_state *state = machine.driver_data<karnov_state>();
8078   int my, mx, offs, color, tile, fx, fy;
81   int scrollx = state->m_scroll[0];
82   int scrolly = state->m_scroll[1];
79   int scrollx = m_scroll[0];
80   int scrolly = m_scroll[1];
8381
84   if (state->m_flipscreen)
82   if (m_flipscreen)
8583      fx = fy = 1;
8684   else
8785      fx = fy = 0;
r20830r20831
9896         my++;
9997      }
10098
101      tile = state->m_pf_data[offs];
99      tile = m_pf_data[offs];
102100      color = tile >> 12;
103101      tile = tile & 0x7ff;
104      if (state->m_flipscreen)
105         drawgfx_opaque(*state->m_bitmap_f, state->m_bitmap_f->cliprect(), machine.gfx[1],tile,
102      if (m_flipscreen)
103         drawgfx_opaque(*m_bitmap_f, m_bitmap_f->cliprect(), machine().gfx[1],tile,
106104            color, fx, fy, 496-16*mx,496-16*my);
107105      else
108         drawgfx_opaque(*state->m_bitmap_f, state->m_bitmap_f->cliprect(), machine.gfx[1],tile,
106         drawgfx_opaque(*m_bitmap_f, m_bitmap_f->cliprect(), machine().gfx[1],tile,
109107            color, fx, fy, 16*mx,16*my);
110108   }
111109
112   if (!state->m_flipscreen)
110   if (!m_flipscreen)
113111   {
114112      scrolly = -scrolly;
115113      scrollx = -scrollx;
r20830r20831
120118      scrollx = scrollx + 256;
121119   }
122120
123   copyscrollbitmap(bitmap, *state->m_bitmap_f, 1, &scrollx, 1, &scrolly, cliprect);
121   copyscrollbitmap(bitmap, *m_bitmap_f, 1, &scrollx, 1, &scrolly, cliprect);
124122}
125123
126124/******************************************************************************/
127125
128126UINT32 karnov_state::screen_update_karnov(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
129127{
130   draw_background(machine(), bitmap, cliprect);
128   draw_background(bitmap, cliprect);
131129   machine().device<deco_karnovsprites_device>("spritegen")->draw_sprites(machine(), bitmap, cliprect, m_spriteram->buffer(), 0x800, 0);
132130   m_fix_tilemap->draw(bitmap, cliprect, 0, 0);
133131   return 0;
trunk/src/mame/video/kingobox.c
r20830r20831
2323
2424***************************************************************************/
2525
26static void palette_init_common( running_machine &machine, const UINT8 *color_prom, void (*get_rgb_data)(const UINT8 *, int, int *, int *, int *) )
26void kingofb_state::palette_init_common( const UINT8 *color_prom, void (kingofb_state::*get_rgb_data)(const UINT8 *, int, int *, int *, int *) )
2727{
2828   static const int resistances[4] = { 1500, 750, 360, 180 };
2929   static const int resistances_fg[1] = { 51 };
r20830r20831
4343                  4, resistances, bweights, 470, 0);
4444
4545   /* allocate the colortable */
46   machine.colortable = colortable_alloc(machine, 0x108);
46   machine().colortable = colortable_alloc(machine(), 0x108);
4747
4848   for (i = 0; i < 0x100; i++)
4949   {
r20830r20831
5151      int bit0, bit1, bit2, bit3;
5252      int r, g, b;
5353
54      get_rgb_data(color_prom, i, &r_data, &g_data, &b_data);
54      (this->*get_rgb_data)(color_prom, i, &r_data, &g_data, &b_data);
5555
5656      /* red component */
5757      bit0 = (r_data >> 0) & 0x01;
r20830r20831
7474      bit3 = (b_data >> 3) & 0x01;
7575      b = combine_4_weights(bweights, bit0, bit1, bit2, bit3);
7676
77      colortable_palette_set_color(machine.colortable, i, MAKE_RGB(r, g, b));
77      colortable_palette_set_color(machine().colortable, i, MAKE_RGB(r, g, b));
7878   }
7979
8080   /* the foreground chars directly map to primary colors */
r20830r20831
9191      /* blue component */
9292      b = (((i - 0x100) >> 0) & 0x01) * bweights_fg[0];
9393
94      colortable_palette_set_color(machine.colortable, i, MAKE_RGB(r, g, b));
94      colortable_palette_set_color(machine().colortable, i, MAKE_RGB(r, g, b));
9595   }
9696
9797   for (i = 0; i < 0x100; i++)
98      colortable_entry_set_value(machine.colortable, i, i);
98      colortable_entry_set_value(machine().colortable, i, i);
9999
100100   for (i = 0x101; i < 0x110; i += 2)
101101   {
102102      UINT16 ctabentry = ((i - 0x101) >> 1) | 0x100;
103      colortable_entry_set_value(machine.colortable, i, ctabentry);
103      colortable_entry_set_value(machine().colortable, i, ctabentry);
104104   }
105105}
106106
107107
108static void kingofb_get_rgb_data( const UINT8 *color_prom, int i, int *r_data, int *g_data, int *b_data )
108void kingofb_state::kingofb_get_rgb_data( const UINT8 *color_prom, int i, int *r_data, int *g_data, int *b_data )
109109{
110110   *r_data = color_prom[i + 0x000] & 0x0f;
111111   *g_data = color_prom[i + 0x100] & 0x0f;
r20830r20831
113113}
114114
115115
116static void ringking_get_rgb_data( const UINT8 *color_prom, int i, int *r_data, int *g_data, int *b_data )
116void kingofb_state::ringking_get_rgb_data( const UINT8 *color_prom, int i, int *r_data, int *g_data, int *b_data )
117117{
118118   *r_data = (color_prom[i + 0x000] >> 4) & 0x0f;
119119   *g_data = (color_prom[i + 0x000] >> 0) & 0x0f;
r20830r20831
124124PALETTE_INIT_MEMBER(kingofb_state,kingofb)
125125{
126126   const UINT8 *color_prom = machine().root_device().memregion("proms")->base();
127   palette_init_common(machine(), color_prom, kingofb_get_rgb_data);
127   palette_init_common(color_prom, &kingofb_state::kingofb_get_rgb_data);
128128}
129129
130130PALETTE_INIT_MEMBER(kingofb_state,ringking)
131131{
132132   const UINT8 *color_prom = machine().root_device().memregion("proms")->base();
133   palette_init_common(machine(), color_prom, ringking_get_rgb_data);
133   palette_init_common(color_prom, &kingofb_state::ringking_get_rgb_data);
134134}
135135
136136WRITE8_MEMBER(kingofb_state::kingofb_videoram_w)
r20830r20831
202202   m_fg_tilemap->set_transparent_pen(0);
203203}
204204
205static void kingofb_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect)
205void kingofb_state::kingofb_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
206206{
207   kingofb_state *state = machine.driver_data<kingofb_state>();
208   UINT8 *spriteram = state->m_spriteram;
207   UINT8 *spriteram = m_spriteram;
209208   int offs;
210209
211   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
210   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
212211   {
213212      int roffs, bank, code, color, flipx, flipy, sx, sy;
214213
r20830r20831
219218
220219      bank = (spriteram[roffs + 3] & 0x04) >> 2;
221220      code = spriteram[roffs + 2] + ((spriteram[roffs + 3] & 0x03) << 8);
222      color = ((spriteram[roffs + 3] & 0x70) >> 4) + 8 * state->m_palette_bank;
221      color = ((spriteram[roffs + 3] & 0x70) >> 4) + 8 * m_palette_bank;
223222      flipx = 0;
224223      flipy = spriteram[roffs + 3] & 0x80;
225224      sx = spriteram[roffs + 1];
226225      sy = spriteram[roffs];
227226
228      if (state->flip_screen())
227      if (flip_screen())
229228      {
230229         sx = 240 - sx;
231230         sy = 240 - sy;
r20830r20831
233232         flipy = !flipy;
234233      }
235234
236      drawgfx_transpen(bitmap, cliprect, machine.gfx[2 + bank],
235      drawgfx_transpen(bitmap, cliprect, machine().gfx[2 + bank],
237236         code, color,
238237         flipx, flipy,
239238         sx, sy, 0);
r20830r20831
244243{
245244   m_bg_tilemap->set_scrolly(0, -(*m_scroll_y));
246245   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
247   kingofb_draw_sprites(machine(), bitmap, cliprect);
246   kingofb_draw_sprites(bitmap, cliprect);
248247   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
249248   return 0;
250249}
r20830r20831
267266   m_fg_tilemap->set_transparent_pen(0);
268267}
269268
270static void ringking_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
269void kingofb_state::ringking_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
271270{
272   kingofb_state *state = machine.driver_data<kingofb_state>();
273   UINT8 *spriteram = state->m_spriteram;
271   UINT8 *spriteram = m_spriteram;
274272   int offs;
275273
276   for (offs = 0; offs < state->m_spriteram.bytes(); offs += 4)
274   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
277275   {
278276      int bank = (spriteram[offs + 1] & 0x04) >> 2;
279277      int code = spriteram[offs + 3] + ((spriteram[offs + 1] & 0x03) << 8);
280      int color = ((spriteram[offs + 1] & 0x70) >> 4) + 8 * state->m_palette_bank;
278      int color = ((spriteram[offs + 1] & 0x70) >> 4) + 8 * m_palette_bank;
281279      int flipx = 0;
282280      int flipy = (spriteram[offs + 1] & 0x80) ? 0 : 1;
283281      int sx = spriteram[offs + 2];
284282      int sy = spriteram[offs];
285283
286      if (state->flip_screen())
284      if (flip_screen())
287285      {
288286         sx = 240 - sx;
289287         sy = 240 - sy;
r20830r20831
291289         flipy = !flipy;
292290      }
293291
294      drawgfx_transpen(bitmap, cliprect, machine.gfx[2 + bank],
292      drawgfx_transpen(bitmap, cliprect, machine().gfx[2 + bank],
295293         code, color,
296294         flipx, flipy,
297295         sx, sy, 0);
r20830r20831
302300{
303301   m_bg_tilemap->set_scrolly(0, -(*m_scroll_y));
304302   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
305   ringking_draw_sprites(machine(), bitmap, cliprect);
303   ringking_draw_sprites(bitmap, cliprect);
306304   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
307305   return 0;
308306}
trunk/src/mame/video/kncljoe.c
r20830r20831
176176
177177***************************************************************************/
178178
179static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
179void kncljoe_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
180180{
181   kncljoe_state *state = machine.driver_data<kncljoe_state>();
182   UINT8 *spriteram = state->m_spriteram;
181   UINT8 *spriteram = m_spriteram;
183182   rectangle clip = cliprect;
184   gfx_element *gfx = machine.gfx[1 + state->m_sprite_bank];
183   gfx_element *gfx = machine().gfx[1 + m_sprite_bank];
185184   int i, j;
186185   static const int pribase[4]={0x0180, 0x0080, 0x0100, 0x0000};
187   const rectangle &visarea = machine.primary_screen->visible_area();
186   const rectangle &visarea = machine().primary_screen->visible_area();
188187
189188   /* score covers sprites */
190   if (state->m_flipscreen)
189   if (m_flipscreen)
191190   {
192191      if (clip.max_y > visarea.max_y - 64)
193192         clip.max_y = visarea.max_y - 64;
r20830r20831
215214         if (attr & 0x20)
216215            code += 256;
217216
218         if (state->m_flipscreen)
217         if (m_flipscreen)
219218         {
220219            flipx = !flipx;
221220            flipy = !flipy;
r20830r20831
237236UINT32 kncljoe_state::screen_update_kncljoe(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
238237{
239238   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
240   draw_sprites(machine(), bitmap, cliprect);
239   draw_sprites(bitmap, cliprect);
241240   return 0;
242241}
trunk/src/mame/video/kyugo.c
r20830r20831
142142 *
143143 *************************************/
144144
145static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
145void kyugo_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
146146{
147   kyugo_state *state = machine.driver_data<kyugo_state>();
148
149147   /* sprite information is scattered through memory */
150148   /* and uses a portion of the text layer memory (outside the visible area) */
151   UINT8 *spriteram_area1 = &state->m_spriteram_1[0x28];
152   UINT8 *spriteram_area2 = &state->m_spriteram_2[0x28];
153   UINT8 *spriteram_area3 = &state->m_fgvideoram[0x28];
149   UINT8 *spriteram_area1 = &m_spriteram_1[0x28];
150   UINT8 *spriteram_area2 = &m_spriteram_2[0x28];
151   UINT8 *spriteram_area3 = &m_fgvideoram[0x28];
154152
155153   int n;
156154
r20830r20831
168166      if (sy > 0xf0)
169167         sy -= 256;
170168
171      if (state->m_flipscreen)
169      if (m_flipscreen)
172170         sy = 240 - sy;
173171
174172      color = spriteram_area1[offs + 1] & 0x1f;
r20830r20831
185183         flipx =  attr & 0x08;
186184         flipy =  attr & 0x04;
187185
188         if (state->m_flipscreen)
186         if (m_flipscreen)
189187         {
190188            flipx = !flipx;
191189            flipy = !flipy;
192190         }
193191
194192
195         drawgfx_transpen( bitmap, cliprect,machine.gfx[2],
193         drawgfx_transpen( bitmap, cliprect,machine().gfx[2],
196194                  code,
197195                  color,
198196                  flipx,flipy,
199                  sx,state->m_flipscreen ? sy - 16*y : sy + 16*y, 0 );
197                  sx,m_flipscreen ? sy - 16*y : sy + 16*y, 0 );
200198      }
201199   }
202200}
r20830r20831
212210   m_bg_tilemap->set_scrolly(0, m_scroll_y);
213211
214212   m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
215   draw_sprites(machine(), bitmap, cliprect);
213   draw_sprites(bitmap, cliprect);
216214   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
217215   return 0;
218216}
trunk/src/mame/video/kangaroo.c
r20830r20831
77#include "emu.h"
88#include "includes/kangaroo.h"
99
10static void blitter_execute(running_machine &machine);
11
12
1310/*************************************
1411 *
1512 *  Video setup
r20830r20831
3128 *
3229 *************************************/
3330
34static void videoram_write( running_machine &machine, UINT16 offset, UINT8 data, UINT8 mask )
31void kangaroo_state::videoram_write( UINT16 offset, UINT8 data, UINT8 mask )
3532{
36   kangaroo_state *state = machine.driver_data<kangaroo_state>();
3733   UINT32 expdata, layermask;
3834
3935   /* data contains 4 2-bit values packed as DCBADCBA; expand these into 4 8-bit values */
r20830r20831
5551   if (mask & 0x01) layermask |= 0x0c0c0c0c;
5652
5753   /* update layers */
58   state->m_videoram[offset] = (state->m_videoram[offset] & ~layermask) | (expdata & layermask);
54   m_videoram[offset] = (m_videoram[offset] & ~layermask) | (expdata & layermask);
5955}
6056
6157
6258WRITE8_MEMBER(kangaroo_state::kangaroo_videoram_w)
6359{
64   videoram_write(machine(), offset, data, m_video_control[8]);
60   videoram_write(offset, data, m_video_control[8]);
6561}
6662
6763
r20830r20831
7975   switch (offset)
8076   {
8177      case 5: /* blitter start */
82         blitter_execute(machine());
78         blitter_execute();
8379         break;
8480
8581      case 8: /* bank select */
r20830r20831
9692 *
9793 *************************************/
9894
99static void blitter_execute( running_machine &machine )
95void kangaroo_state::blitter_execute(  )
10096{
101   kangaroo_state *state = machine.driver_data<kangaroo_state>();
102   UINT32 gfxhalfsize = state->memregion("gfx1")->bytes() / 2;
103   const UINT8 *gfxbase = state->memregion("gfx1")->base();
104   UINT16 src = state->m_video_control[0] + 256 * state->m_video_control[1];
105   UINT16 dst = state->m_video_control[2] + 256 * state->m_video_control[3];
106   UINT8 height = state->m_video_control[5];
107   UINT8 width = state->m_video_control[4];
108   UINT8 mask = state->m_video_control[8];
97   UINT32 gfxhalfsize = memregion("gfx1")->bytes() / 2;
98   const UINT8 *gfxbase = memregion("gfx1")->base();
99   UINT16 src = m_video_control[0] + 256 * m_video_control[1];
100   UINT16 dst = m_video_control[2] + 256 * m_video_control[3];
101   UINT8 height = m_video_control[5];
102   UINT8 width = m_video_control[4];
103   UINT8 mask = m_video_control[8];
109104   int x, y;
110105
111106   /* during DMA operations, the top 2 bits are ORed together, as well as the bottom 2 bits */
r20830r20831
119114      {
120115         UINT16 effdst = (dst + x) & 0x3fff;
121116         UINT16 effsrc = src++ & (gfxhalfsize - 1);
122         videoram_write(machine, effdst, gfxbase[0 * gfxhalfsize + effsrc], mask & 0x05);
123         videoram_write(machine, effdst, gfxbase[1 * gfxhalfsize + effsrc], mask & 0x0a);
117         videoram_write(effdst, gfxbase[0 * gfxhalfsize + effsrc], mask & 0x05);
118         videoram_write(effdst, gfxbase[1 * gfxhalfsize + effsrc], mask & 0x0a);
124119      }
125120}
126121
trunk/src/mame/drivers/kickgoal.c
r20830r20831
116116//static int kickgoal_melody;
117117//static int kickgoal_snd_bank;
118118
119static void kickgoal_play(okim6295_device *oki, int melody, int data)
119void ::kickgoal_play(okim6295_device *oki, int melody, int data)
120120{
121121   int status = oki->read(0);
122122
r20830r20831
124124   if (kickgoal_sound == 0) popmessage("Unknown sound command %02x",kickgoal_sound);
125125
126126   if (melody) {
127      if (state->m_melody != kickgoal_sound) {
128         state->m_melody      = kickgoal_sound;
129         state->m_melody_loop = kickgoal_sound;
127      if (m_melody != kickgoal_sound) {
128         m_melody      = kickgoal_sound;
129         m_melody_loop = kickgoal_sound;
130130         if (status & 0x08)
131131            oki->write(0,0x40);
132         oki->write(0,(0x80 | state->m_melody));
132         oki->write(0,(0x80 | m_melody));
133133         oki->write(0,0x81);
134134      }
135135   }
trunk/src/mame/drivers/kchamp.c
r20830r20831
705705ROM_END
706706
707707
708static UINT8 *decrypt_code(running_machine &machine)
708UINT8 *kchamp_state::decrypt_code()
709709{
710   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
711   UINT8 *decrypted = auto_alloc_array(machine, UINT8, 0x10000);
712   UINT8 *rom = machine.root_device().memregion("maincpu")->base();
710   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
711   UINT8 *decrypted = auto_alloc_array(machine(), UINT8, 0x10000);
712   UINT8 *rom = machine().root_device().memregion("maincpu")->base();
713713   int A;
714714
715715   space.set_decrypted_region(0x0000, 0xffff, decrypted);
r20830r20831
724724DRIVER_INIT_MEMBER(kchamp_state,kchampvs)
725725{
726726   UINT8 *rom = memregion("maincpu")->base();
727   UINT8 *decrypted = decrypt_code(machine());
727   UINT8 *decrypted = decrypt_code();
728728   int A;
729729
730730   /*
r20830r20831
754754
755755DRIVER_INIT_MEMBER(kchamp_state,kchampvs2)
756756{
757   decrypt_code(machine());
757   decrypt_code();
758758   m_counter = 0;
759759   m_msm_data = 0;
760760   m_msm_play_lo_nibble = 1;
trunk/src/mame/drivers/kaneko16.c
r20830r20831
632632                                Shogun Warriors
633633***************************************************************************/
634634
635static void kaneko16_common_oki_bank_w( running_machine& machine, const char *bankname, const char* tag, int bank, size_t fixedsize, size_t bankedsize )
635void kaneko16_state::kaneko16_common_oki_bank_w(  const char *bankname, const char* tag, int bank, size_t fixedsize, size_t bankedsize )
636636{
637637   UINT32 bankaddr;
638   UINT8* samples = machine.root_device().memregion(tag)->base();
639   size_t length = machine.root_device().memregion(tag)->bytes();
638   UINT8* samples = machine().root_device().memregion(tag)->base();
639   size_t length = machine().root_device().memregion(tag)->bytes();
640640
641641   bankaddr = fixedsize + (bankedsize * bank);
642642
643643   if (bankaddr <= (length-bankedsize))
644644   {
645      machine.root_device().membank(bankname)->set_base(samples + bankaddr);
645      machine().root_device().membank(bankname)->set_base(samples + bankaddr);
646646   }
647647}
648648
r20830r20831
650650{
651651   if (ACCESSING_BITS_0_7)
652652   {
653      kaneko16_common_oki_bank_w(machine(), "bank10", "oki1", (data >> 4) & 0xf, 0x30000, 0x10000);
654      kaneko16_common_oki_bank_w(machine(), "bank11", "oki2", (data & 0xf)     , 0x00000, 0x40000);
653      kaneko16_common_oki_bank_w("bank10", "oki1", (data >> 4) & 0xf, 0x30000, 0x10000);
654      kaneko16_common_oki_bank_w("bank11", "oki2", (data & 0xf)     , 0x00000, 0x40000);
655655   }
656656}
657657
r20830r20831
659659{
660660   if (ACCESSING_BITS_0_7)
661661   {
662      kaneko16_common_oki_bank_w(machine(), "bank10", "oki1", (data >> 4) & 0xf, 0x30000, 0x10000);
663      kaneko16_common_oki_bank_w(machine(), "bank11", "oki2", (data & 0xf)     , 0x20000, 0x20000);
662      kaneko16_common_oki_bank_w("bank10", "oki1", (data >> 4) & 0xf, 0x30000, 0x10000);
663      kaneko16_common_oki_bank_w("bank11", "oki2", (data & 0xf)     , 0x20000, 0x20000);
664664   }
665665}
666666
r20830r20831
21552155 have the even and odd pixels swapped. So we use this function to untangle
21562156 them and have one single gfxlayout for both tiles and sprites.
21572157*/
2158static void kaneko16_unscramble_tiles(running_machine &machine, const char *region)
2158void kaneko16_state::kaneko16_unscramble_tiles(const char *region)
21592159{
2160   UINT8 *RAM  =   machine.root_device().memregion(region)->base();
2161   int size            =   machine.root_device().memregion(region)->bytes();
2160   UINT8 *RAM  =   machine().root_device().memregion(region)->base();
2161   int size            =   machine().root_device().memregion(region)->bytes();
21622162   int i;
21632163
21642164   if (RAM == NULL)    return;
r20830r20831
21692169   }
21702170}
21712171
2172static void kaneko16_expand_sample_banks(running_machine &machine, const char *region)
2172void kaneko16_state::kaneko16_expand_sample_banks(const char *region)
21732173{
21742174   /* The sample data for the first OKI has an address translator/
21752175      banking register in it that munges the addresses as follows:
r20830r20831
21832183   int bank;
21842184   UINT8 *src0;
21852185
2186   if (machine.root_device().memregion(region)->bytes() < 0x40000 * 16)
2186   if (machine().root_device().memregion(region)->bytes() < 0x40000 * 16)
21872187      fatalerror("gtmr SOUND1 region too small\n");
21882188
21892189   /* bank 0 maps to itself, so we just leave it alone */
2190   src0 = machine.root_device().memregion(region)->base();
2190   src0 = machine().root_device().memregion(region)->base();
21912191   for (bank = 15; bank > 0; bank--)
21922192   {
21932193      UINT8 *srcn = src0 + 0x10000 * (bank < 3 ? 3 : bank);
r20830r20831
22002200
22012201DRIVER_INIT_MEMBER( kaneko16_state, kaneko16 )
22022202{
2203   kaneko16_unscramble_tiles(machine(), "gfx2");
2204   kaneko16_unscramble_tiles(machine(), "gfx3");
2203   kaneko16_unscramble_tiles("gfx2");
2204   kaneko16_unscramble_tiles("gfx3");
22052205}
22062206
22072207DRIVER_INIT_MEMBER( kaneko16_berlwall_state, berlwall )
22082208{
2209   kaneko16_unscramble_tiles(machine(), "gfx2");
2209   kaneko16_unscramble_tiles("gfx2");
22102210}
22112211
22122212DRIVER_INIT_MEMBER( kaneko16_state, samplebank )
22132213{
2214   kaneko16_unscramble_tiles(machine(), "gfx2");
2215   kaneko16_unscramble_tiles(machine(), "gfx3");
2216   kaneko16_expand_sample_banks(machine(), "oki1");
2214   kaneko16_unscramble_tiles("gfx2");
2215   kaneko16_unscramble_tiles("gfx3");
2216   kaneko16_expand_sample_banks("oki1");
22172217}
22182218
22192219
r20830r20831
38293829DRIVER_INIT_MEMBER( kaneko16_shogwarr_state, shogwarr )
38303830{
38313831   // default sample banks
3832   kaneko16_common_oki_bank_w(machine(), "bank10", "oki1", 0, 0x30000, 0x10000);
3833   kaneko16_common_oki_bank_w(machine(), "bank11", "oki2", 0, 0x00000, 0x40000);
3832   kaneko16_common_oki_bank_w("bank10", "oki1", 0, 0x30000, 0x10000);
3833   kaneko16_common_oki_bank_w("bank11", "oki2", 0, 0x00000, 0x40000);
38343834   DRIVER_INIT_CALL(kaneko16);
38353835}
38363836
r20830r20831
38413841   machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xe00000, 0xe00001, write16_delegate(FUNC(kaneko16_shogwarr_state::brapboys_oki_bank_w),this));
38423842
38433843   // default sample banks
3844   kaneko16_common_oki_bank_w(machine(), "bank10", "oki1", 0, 0x30000, 0x10000);
3845   kaneko16_common_oki_bank_w(machine(), "bank11", "oki2", 0, 0x20000, 0x20000);
3844   kaneko16_common_oki_bank_w("bank10", "oki1", 0, 0x30000, 0x10000);
3845   kaneko16_common_oki_bank_w("bank11", "oki2", 0, 0x20000, 0x20000);
38463846   DRIVER_INIT_CALL(kaneko16);
38473847}
38483848
trunk/src/mame/drivers/karnov.c
r20830r20831
9191 *************************************/
9292
9393/* Emulation of the protected microcontroller - for coins & general protection */
94static void karnov_i8751_w( running_machine &machine, int data )
94void karnov_state::karnov_i8751_w( int data )
9595{
96   karnov_state *state = machine.driver_data<karnov_state>();
97
9896   /* Pending coin operations may cause protection commands to be queued */
99   if (state->m_i8751_needs_ack)
97   if (m_i8751_needs_ack)
10098   {
101      state->m_i8751_command_queue = data;
99      m_i8751_command_queue = data;
102100      return;
103101   }
104102
105   state->m_i8751_return = 0;
103   m_i8751_return = 0;
106104
107   if (data == 0x100 && state->m_microcontroller_id == KARNOV) /* USA version */
108      state->m_i8751_return = 0x56b;
105   if (data == 0x100 && m_microcontroller_id == KARNOV) /* USA version */
106      m_i8751_return = 0x56b;
109107
110   if (data == 0x100 && state->m_microcontroller_id == KARNOVJ)    /* Japan version */
111      state->m_i8751_return = 0x56a;
108   if (data == 0x100 && m_microcontroller_id == KARNOVJ)    /* Japan version */
109      m_i8751_return = 0x56a;
112110
113111   if ((data & 0xf00) == 0x300)
114      state->m_i8751_return = (data & 0xff) * 0x12; /* Player sprite mapping */
112      m_i8751_return = (data & 0xff) * 0x12; /* Player sprite mapping */
115113
116114   /* I'm not sure the ones marked ^ appear in the right order */
117   if (data == 0x400) state->m_i8751_return = 0x4000; /* Get The Map... */
118   if (data == 0x402) state->m_i8751_return = 0x40a6; /* Ancient Ruins */
119   if (data == 0x403) state->m_i8751_return = 0x4054; /* Forest... */
120   if (data == 0x404) state->m_i8751_return = 0x40de; /* ^Rocky hills */
121   if (data == 0x405) state->m_i8751_return = 0x4182; /* Sea */
122   if (data == 0x406) state->m_i8751_return = 0x41ca; /* Town */
123   if (data == 0x407) state->m_i8751_return = 0x421e; /* Desert */
124   if (data == 0x401) state->m_i8751_return = 0x4138; /* ^Whistling wind */
125   if (data == 0x408) state->m_i8751_return = 0x4276; /* ^Heavy Gates */
115   if (data == 0x400) m_i8751_return = 0x4000; /* Get The Map... */
116   if (data == 0x402) m_i8751_return = 0x40a6; /* Ancient Ruins */
117   if (data == 0x403) m_i8751_return = 0x4054; /* Forest... */
118   if (data == 0x404) m_i8751_return = 0x40de; /* ^Rocky hills */
119   if (data == 0x405) m_i8751_return = 0x4182; /* Sea */
120   if (data == 0x406) m_i8751_return = 0x41ca; /* Town */
121   if (data == 0x407) m_i8751_return = 0x421e; /* Desert */
122   if (data == 0x401) m_i8751_return = 0x4138; /* ^Whistling wind */
123   if (data == 0x408) m_i8751_return = 0x4276; /* ^Heavy Gates */
126124
127//  if (!state->m_i8751_return && data != 0x300) logerror("%s - Unknown Write %02x intel\n", machine.describe_context(), data);
125//  if (!m_i8751_return && data != 0x300) logerror("%s - Unknown Write %02x intel\n", machine().describe_context(), data);
128126
129   state->m_maincpu->set_input_line(6, HOLD_LINE); /* Signal main cpu task is complete */
130   state->m_i8751_needs_ack = 1;
127   m_maincpu->set_input_line(6, HOLD_LINE); /* Signal main cpu task is complete */
128   m_i8751_needs_ack = 1;
131129}
132130
133static void wndrplnt_i8751_w( running_machine &machine, int data )
131void karnov_state::wndrplnt_i8751_w( int data )
134132{
135   karnov_state *state = machine.driver_data<karnov_state>();
136
137133   /* The last command hasn't been ACK'd (probably a conflict with coin command) */
138   if (state->m_i8751_needs_ack)
134   if (m_i8751_needs_ack)
139135   {
140      state->m_i8751_command_queue = data;
136      m_i8751_command_queue = data;
141137      return;
142138   }
143139
144   state->m_i8751_return=0;
140   m_i8751_return=0;
145141
146   if (data == 0x100) state->m_i8751_return = 0x67a;
147   if (data == 0x200) state->m_i8751_return = 0x214;
148   if (data == 0x300) state->m_i8751_return = 0x17; /* Copyright text on title screen */
149//  if (data == 0x300) state->m_i8751_return = 0x1; /* (USA) Copyright text on title screen */
142   if (data == 0x100) m_i8751_return = 0x67a;
143   if (data == 0x200) m_i8751_return = 0x214;
144   if (data == 0x300) m_i8751_return = 0x17; /* Copyright text on title screen */
145//  if (data == 0x300) m_i8751_return = 0x1; /* (USA) Copyright text on title screen */
150146
151147   /* The game writes many values in the 0x600 range, but only a specific mask
152148   matters for the return value */
r20830r20831
154150   {
155151      switch (data & 0x18)
156152      {
157         case 0x00:  state->m_i8751_return = 0x4d53; break;
158         case 0x08:  state->m_i8751_return = 0x4b54; break;
159         case 0x10:  state->m_i8751_return = 0x5453; break;
160         case 0x18:  state->m_i8751_return = 0x5341; break;
153         case 0x00:  m_i8751_return = 0x4d53; break;
154         case 0x08:  m_i8751_return = 0x4b54; break;
155         case 0x10:  m_i8751_return = 0x5453; break;
156         case 0x18:  m_i8751_return = 0x5341; break;
161157      }
162158   }
163//  else logerror("%s - Unknown Write %02x intel\n", machine.describe_context(), data);
159//  else logerror("%s - Unknown Write %02x intel\n", machine().describe_context(), data);
164160
165161   /* These are 68k function call addresses - different address for each power-up */
166   if (data == 0x400) state->m_i8751_return = 0x594;
167   if (data == 0x401) state->m_i8751_return = 0x5ea;
168   if (data == 0x402) state->m_i8751_return = 0x628;
169   if (data == 0x403) state->m_i8751_return = 0x66c;
170   if (data == 0x404) state->m_i8751_return = 0x6a4;
171   if (data == 0x405) state->m_i8751_return = 0x6a4;
172   if (data == 0x406) state->m_i8751_return = 0x6a4;
162   if (data == 0x400) m_i8751_return = 0x594;
163   if (data == 0x401) m_i8751_return = 0x5ea;
164   if (data == 0x402) m_i8751_return = 0x628;
165   if (data == 0x403) m_i8751_return = 0x66c;
166   if (data == 0x404) m_i8751_return = 0x6a4;
167   if (data == 0x405) m_i8751_return = 0x6a4;
168   if (data == 0x406) m_i8751_return = 0x6a4;
173169
174170   /* This is 68k program code which is executed every frame */
175   if (data == 0x50c) state->m_i8751_return = 0x13fc;
176   if (data == 0x50b) state->m_i8751_return = 0x00ff;
177   if (data == 0x50a) state->m_i8751_return = 0x0006;
178   if (data == 0x509) state->m_i8751_return = 0x0000;
179   if (data == 0x508) state->m_i8751_return = 0x4a39;
180   if (data == 0x507) state->m_i8751_return = 0x0006;
181   if (data == 0x506) state->m_i8751_return = 0x0000;
182   if (data == 0x505) state->m_i8751_return = 0x66f8;
183   if (data == 0x504) state->m_i8751_return = 0x4a39;
184   if (data == 0x503) state->m_i8751_return = 0x000c;
185   if (data == 0x502) state->m_i8751_return = 0x0003;
186   if (data == 0x501) state->m_i8751_return = 0x6bf8;
187   if (data == 0x500) state->m_i8751_return = 0x4e75;
171   if (data == 0x50c) m_i8751_return = 0x13fc;
172   if (data == 0x50b) m_i8751_return = 0x00ff;
173   if (data == 0x50a) m_i8751_return = 0x0006;
174   if (data == 0x509) m_i8751_return = 0x0000;
175   if (data == 0x508) m_i8751_return = 0x4a39;
176   if (data == 0x507) m_i8751_return = 0x0006;
177   if (data == 0x506) m_i8751_return = 0x0000;
178   if (data == 0x505) m_i8751_return = 0x66f8;
179   if (data == 0x504) m_i8751_return = 0x4a39;
180   if (data == 0x503) m_i8751_return = 0x000c;
181   if (data == 0x502) m_i8751_return = 0x0003;
182   if (data == 0x501) m_i8751_return = 0x6bf8;
183   if (data == 0x500) m_i8751_return = 0x4e75;
188184
189   state->m_maincpu->set_input_line(6, HOLD_LINE); /* Signal main cpu task is complete */
190   state->m_i8751_needs_ack = 1;
185   m_maincpu->set_input_line(6, HOLD_LINE); /* Signal main cpu task is complete */
186   m_i8751_needs_ack = 1;
191187}
192188
193static void chelnov_i8751_w( running_machine &machine, int data )
189void karnov_state::chelnov_i8751_w( int data )
194190{
195   karnov_state *state = machine.driver_data<karnov_state>();
196
197191   /* Pending coin operations may cause protection commands to be queued */
198   if (state->m_i8751_needs_ack)
192   if (m_i8751_needs_ack)
199193   {
200      state->m_i8751_command_queue = data;
194      m_i8751_command_queue = data;
201195      return;
202196   }
203197
204   state->m_i8751_return = 0;
198   m_i8751_return = 0;
205199
206   if (data == 0x200 && state->m_microcontroller_id == CHELNOV)    /* World version */
207      state->m_i8751_return = 0x7736;
200   if (data == 0x200 && m_microcontroller_id == CHELNOV)    /* World version */
201      m_i8751_return = 0x7736;
208202
209   if (data == 0x200 && state->m_microcontroller_id == CHELNOVU)   /* USA version */
210      state->m_i8751_return = 0x783e;
203   if (data == 0x200 && m_microcontroller_id == CHELNOVU)   /* USA version */
204      m_i8751_return = 0x783e;
211205
212   if (data == 0x200 && state->m_microcontroller_id == CHELNOVJ)   /* Japan version */
213      state->m_i8751_return = 0x7734;
206   if (data == 0x200 && m_microcontroller_id == CHELNOVJ)   /* Japan version */
207      m_i8751_return = 0x7734;
214208
215   if (data == 0x100 && state->m_microcontroller_id == CHELNOV)    /* World version */
216      state->m_i8751_return = 0x71c;
209   if (data == 0x100 && m_microcontroller_id == CHELNOV)    /* World version */
210      m_i8751_return = 0x71c;
217211
218   if (data == 0x100 && state->m_microcontroller_id == CHELNOVU)   /* USA version */
219      state->m_i8751_return = 0x71b;
212   if (data == 0x100 && m_microcontroller_id == CHELNOVU)   /* USA version */
213      m_i8751_return = 0x71b;
220214
221   if (data == 0x100 && state->m_microcontroller_id == CHELNOVJ)   /* Japan version */
222      state->m_i8751_return = 0x71a;
215   if (data == 0x100 && m_microcontroller_id == CHELNOVJ)   /* Japan version */
216      m_i8751_return = 0x71a;
223217
224218   if (data >= 0x6000 && data < 0x8000)
225      state->m_i8751_return = 1;  /* patched */
219      m_i8751_return = 1;  /* patched */
226220
227   if ((data & 0xf000) == 0x1000) state->m_i8751_level = 1;        /* Level 1 */
228   if ((data & 0xf000) == 0x2000) state->m_i8751_level++;      /* Level Increment */
221   if ((data & 0xf000) == 0x1000) m_i8751_level = 1;        /* Level 1 */
222   if ((data & 0xf000) == 0x2000) m_i8751_level++;      /* Level Increment */
229223
230224   if ((data & 0xf000) == 0x3000)
231225   {
232226      /* Sprite table mapping */
233227      int b = data & 0xff;
234      switch (state->m_i8751_level)
228      switch (m_i8751_level)
235229      {
236230         case 1: /* Level 1, Sprite mapping tables */
237            if (state->m_microcontroller_id == CHELNOVU) /* USA */
231            if (m_microcontroller_id == CHELNOVU) /* USA */
238232            {
239               if (b < 2) state->m_i8751_return = 0;
240               else if (b < 6) state->m_i8751_return = 1;
241               else if (b < 0xb) state->m_i8751_return = 2;
242               else if (b < 0xf) state->m_i8751_return = 3;
243               else if (b < 0x13) state->m_i8751_return = 4;
244               else state->m_i8751_return = 5;
233               if (b < 2) m_i8751_return = 0;
234               else if (b < 6) m_i8751_return = 1;
235               else if (b < 0xb) m_i8751_return = 2;
236               else if (b < 0xf) m_i8751_return = 3;
237               else if (b < 0x13) m_i8751_return = 4;
238               else m_i8751_return = 5;
245239            }
246240            else    /* Japan, World */
247241            {
248               if (b < 3) state->m_i8751_return = 0;
249               else if (b < 8) state->m_i8751_return = 1;
250               else if (b < 0xc) state->m_i8751_return = 2;
251               else if (b < 0x10) state->m_i8751_return = 3;
252               else if (b < 0x19) state->m_i8751_return = 4;
253               else if (b < 0x1b) state->m_i8751_return = 5;
254               else if (b < 0x22) state->m_i8751_return = 6;
255               else if (b < 0x28) state->m_i8751_return = 7;
256               else state->m_i8751_return = 8;
242               if (b < 3) m_i8751_return = 0;
243               else if (b < 8) m_i8751_return = 1;
244               else if (b < 0xc) m_i8751_return = 2;
245               else if (b < 0x10) m_i8751_return = 3;
246               else if (b < 0x19) m_i8751_return = 4;
247               else if (b < 0x1b) m_i8751_return = 5;
248               else if (b < 0x22) m_i8751_return = 6;
249               else if (b < 0x28) m_i8751_return = 7;
250               else m_i8751_return = 8;
257251            }
258252            break;
259253         case 2: /* Level 2, Sprite mapping tables, all sets are the same */
260            if (b < 3) state->m_i8751_return = 0;
261            else if (b < 9) state->m_i8751_return = 1;
262            else if (b < 0x11) state->m_i8751_return = 2;
263            else if (b < 0x1b) state->m_i8751_return = 3;
264            else if (b < 0x21) state->m_i8751_return = 4;
265            else if (b < 0x28) state->m_i8751_return = 5;
266            else state->m_i8751_return = 6;
254            if (b < 3) m_i8751_return = 0;
255            else if (b < 9) m_i8751_return = 1;
256            else if (b < 0x11) m_i8751_return = 2;
257            else if (b < 0x1b) m_i8751_return = 3;
258            else if (b < 0x21) m_i8751_return = 4;
259            else if (b < 0x28) m_i8751_return = 5;
260            else m_i8751_return = 6;
267261            break;
268262         case 3: /* Level 3, Sprite mapping tables, all sets are the same */
269            if (b < 5) state->m_i8751_return = 0;
270            else if (b < 9) state->m_i8751_return = 1;
271            else if (b < 0xd) state->m_i8751_return = 2;
272            else if (b < 0x11) state->m_i8751_return = 3;
273            else if (b < 0x1b) state->m_i8751_return = 4;
274            else if (b < 0x1c) state->m_i8751_return = 5;
275            else if (b < 0x22) state->m_i8751_return = 6;
276            else if (b < 0x27) state->m_i8751_return = 7;
277            else state->m_i8751_return = 8;
263            if (b < 5) m_i8751_return = 0;
264            else if (b < 9) m_i8751_return = 1;
265            else if (b < 0xd) m_i8751_return = 2;
266            else if (b < 0x11) m_i8751_return = 3;
267            else if (b < 0x1b) m_i8751_return = 4;
268            else if (b < 0x1c) m_i8751_return = 5;
269            else if (b < 0x22) m_i8751_return = 6;
270            else if (b < 0x27) m_i8751_return = 7;
271            else m_i8751_return = 8;
278272            break;
279273         case 4: /* Level 4, Sprite mapping tables, all sets are the same */
280            if (b < 4) state->m_i8751_return = 0;
281            else if (b < 0xc) state->m_i8751_return = 1;
282            else if (b < 0xf) state->m_i8751_return = 2;
283            else if (b < 0x19) state->m_i8751_return = 3;
284            else if (b < 0x1c) state->m_i8751_return = 4;
285            else if (b < 0x22) state->m_i8751_return = 5;
286            else if (b < 0x29) state->m_i8751_return = 6;
287            else state->m_i8751_return = 7;
274            if (b < 4) m_i8751_return = 0;
275            else if (b < 0xc) m_i8751_return = 1;
276            else if (b < 0xf) m_i8751_return = 2;
277            else if (b < 0x19) m_i8751_return = 3;
278            else if (b < 0x1c) m_i8751_return = 4;
279            else if (b < 0x22) m_i8751_return = 5;
280            else if (b < 0x29) m_i8751_return = 6;
281            else m_i8751_return = 7;
288282            break;
289283         case 5: /* Level 5, Sprite mapping tables, all sets are the same  */
290            if (b < 7) state->m_i8751_return = 0;
291            else if (b < 0xe) state->m_i8751_return = 1;
292            else if (b < 0x14) state->m_i8751_return = 2;
293            else if (b < 0x1a) state->m_i8751_return = 3;
294            else if (b < 0x23) state->m_i8751_return = 4;
295            else if (b < 0x27) state->m_i8751_return = 5;
296            else state->m_i8751_return = 6;
284            if (b < 7) m_i8751_return = 0;
285            else if (b < 0xe) m_i8751_return = 1;
286            else if (b < 0x14) m_i8751_return = 2;
287            else if (b < 0x1a) m_i8751_return = 3;
288            else if (b < 0x23) m_i8751_return = 4;
289            else if (b < 0x27) m_i8751_return = 5;
290            else m_i8751_return = 6;
297291            break;
298292         case 6: /* Level 6, Sprite mapping tables, all sets are the same  */
299            if (b < 3) state->m_i8751_return = 0;
300            else if (b < 0xb) state->m_i8751_return = 1;
301            else if (b < 0x11) state->m_i8751_return = 2;
302            else if (b < 0x17) state->m_i8751_return = 3;
303            else if (b < 0x1d) state->m_i8751_return = 4;
304            else if (b < 0x24) state->m_i8751_return = 5;
305            else state->m_i8751_return = 6;
293            if (b < 3) m_i8751_return = 0;
294            else if (b < 0xb) m_i8751_return = 1;
295            else if (b < 0x11) m_i8751_return = 2;
296            else if (b < 0x17) m_i8751_return = 3;
297            else if (b < 0x1d) m_i8751_return = 4;
298            else if (b < 0x24) m_i8751_return = 5;
299            else m_i8751_return = 6;
306300            break;
307301         case 7: /* Level 7, Sprite mapping tables, all sets are the same  */
308            if (b < 5) state->m_i8751_return = 0;
309            else if (b < 0xb) state->m_i8751_return = 1;
310            else if (b < 0x11) state->m_i8751_return = 2;
311            else if (b < 0x1a) state->m_i8751_return = 3;
312            else if (b < 0x21) state->m_i8751_return = 4;
313            else if (b < 0x27) state->m_i8751_return = 5;
314            else state->m_i8751_return = 6;
302            if (b < 5) m_i8751_return = 0;
303            else if (b < 0xb) m_i8751_return = 1;
304            else if (b < 0x11) m_i8751_return = 2;
305            else if (b < 0x1a) m_i8751_return = 3;
306            else if (b < 0x21) m_i8751_return = 4;
307            else if (b < 0x27) m_i8751_return = 5;
308            else m_i8751_return = 6;
315309            break;
316310      }
317311   }
318312
319   //  logerror("%s - Unknown Write %02x intel\n", machine.describe_context(), data);
313   //  logerror("%s - Unknown Write %02x intel\n", machine().describe_context(), data);
320314
321   state->m_maincpu->set_input_line(6, HOLD_LINE); /* Signal main cpu task is complete */
322   state->m_i8751_needs_ack = 1;
315   m_maincpu->set_input_line(6, HOLD_LINE); /* Signal main cpu task is complete */
316   m_i8751_needs_ack = 1;
323317}
324318
325319/*************************************
r20830r20831
370364
371365      case 6: /* SECREQ (Interrupt & Data to i8751) */
372366         if (m_microcontroller_id == KARNOV || m_microcontroller_id == KARNOVJ)
373            karnov_i8751_w(machine(), data);
367            karnov_i8751_w(data);
374368         if (m_microcontroller_id == CHELNOV || m_microcontroller_id == CHELNOVU || m_microcontroller_id == CHELNOVJ)
375            chelnov_i8751_w(machine(), data);
369            chelnov_i8751_w(data);
376370         if (m_microcontroller_id == WNDRPLNT)
377            wndrplnt_i8751_w(machine(), data);
371            wndrplnt_i8751_w(data);
378372         break;
379373
380374      case 8: /* HSHIFT (9 bits) - Top bit indicates video flip */
381375         COMBINE_DATA(&m_scroll[0]);
382         karnov_flipscreen_w(machine(), data >> 15);
376         karnov_flipscreen_w(data >> 15);
383377         break;
384378
385379      case 0xa: /* VSHIFT */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team