Previous 199869 Revisions Next

r20835 Friday 8th February, 2013 at 14:37:46 UTC by Miodrag Milanović
More cleanup (nw)
[src/mame/drivers]redclash.c
[src/mame/includes]ladybug.h
[src/mame/video]ladybug.c redclash.c

trunk/src/mame/video/ladybug.c
r20834r20835
175175
176176   m_grid_color = data & 0x70;
177177
178   redclash_set_stars_enable(machine(), (data & 0x08) >> 3);
178   redclash_set_stars_enable((data & 0x08) >> 3);
179179
180180   /*
181181    * There must be a subtle clocking difference between
r20834r20835
183183    * hence the -1 here
184184    */
185185
186   redclash_set_stars_speed(machine(), (data & 0x07) - 1);
186   redclash_set_stars_speed((data & 0x07) - 1);
187187}
188188
189189TILE_GET_INFO_MEMBER(ladybug_state::get_bg_tile_info)
r20834r20835
301301{
302302   // falling edge
303303   if (!state)
304      redclash_update_stars_state(machine());
304      redclash_update_stars_state();
305305}
306306
307307UINT32 ladybug_state::screen_update_sraider(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r20834r20835
328328
329329   // draw the stars
330330   if (flip_screen())
331      redclash_draw_stars(machine(), bitmap, cliprect, 0x60, 1, 0x27, 0xff);
331      redclash_draw_stars(bitmap, cliprect, 0x60, 1, 0x27, 0xff);
332332   else
333      redclash_draw_stars(machine(), bitmap, cliprect, 0x60, 1, 0x00, 0xd8);
333      redclash_draw_stars(bitmap, cliprect, 0x60, 1, 0x00, 0xd8);
334334
335335   // draw the gridlines
336336   colortable_palette_set_color(machine().colortable, 0x40, MAKE_RGB(m_grid_color & 0x40 ? 0xff : 0,
trunk/src/mame/video/redclash.c
r20834r20835
100100      colortable_entry_set_value(machine().colortable, i, (i - 0x60) + 0x20);
101101}
102102
103WRITE8_HANDLER( redclash_videoram_w )
103WRITE8_HANDLER( ladybug_state::redclash_videoram_w )
104104{
105   ladybug_state *state = space.machine().driver_data<ladybug_state>();
106
107   state->m_videoram[offset] = data;
108   state->m_fg_tilemap->mark_tile_dirty(offset);
105   m_videoram[offset] = data;
106   m_fg_tilemap->mark_tile_dirty(offset);
109107}
110108
111WRITE8_HANDLER( redclash_gfxbank_w )
109WRITE8_HANDLER( ladybug_state::redclash_gfxbank_w )
112110{
113   ladybug_state *state = space.machine().driver_data<ladybug_state>();
114
115   if (state->m_gfxbank != (data & 0x01))
111   if (m_gfxbank != (data & 0x01))
116112   {
117      state->m_gfxbank = data & 0x01;
118      space.machine().tilemap().mark_all_dirty();
113      m_gfxbank = data & 0x01;
114      machine().tilemap().mark_all_dirty();
119115   }
120116}
121117
122WRITE8_HANDLER( redclash_flipscreen_w )
118WRITE8_HANDLER( ladybug_state::redclash_flipscreen_w )
123119{
124   ladybug_state *state = space.machine().driver_data<ladybug_state>();
125   state->flip_screen_set(data & 0x01);
120   flip_screen_set(data & 0x01);
126121}
127122
128void redclash_set_stars_enable( running_machine &machine, UINT8 on ); //temp
129void redclash_set_stars_speed( running_machine &machine, UINT8 speed );  //temp
130
131123/*
132124star_speed:
1331250 = unused
r20834r20835
1391316 = backwards medium
1401327 = backwards fast
141133*/
142WRITE8_HANDLER( redclash_star0_w )
134WRITE8_HANDLER( ladybug_state::redclash_star0_w )
143135{
144   ladybug_state *state = space.machine().driver_data<ladybug_state>();
145
146   state->m_star_speed = (state->m_star_speed & ~1) | ((data & 1) << 0);
147   redclash_set_stars_speed(space.machine(), state->m_star_speed);
136   m_star_speed = (m_star_speed & ~1) | ((data & 1) << 0);
137   redclash_set_stars_speed(m_star_speed);
148138}
149139
150WRITE8_HANDLER( redclash_star1_w )
140WRITE8_HANDLER( ladybug_state::redclash_star1_w )
151141{
152   ladybug_state *state = space.machine().driver_data<ladybug_state>();
153
154   state->m_star_speed = (state->m_star_speed & ~2) | ((data & 1) << 1);
155   redclash_set_stars_speed(space.machine(), state->m_star_speed);
142   m_star_speed = (m_star_speed & ~2) | ((data & 1) << 1);
143   redclash_set_stars_speed(m_star_speed);
156144}
157145
158WRITE8_HANDLER( redclash_star2_w )
146WRITE8_HANDLER( ladybug_state::redclash_star2_w )
159147{
160   ladybug_state *state = space.machine().driver_data<ladybug_state>();
161
162   state->m_star_speed = (state->m_star_speed & ~4) | ((data & 1) << 2);
163   redclash_set_stars_speed(space.machine(), state->m_star_speed);
148   m_star_speed = (m_star_speed & ~4) | ((data & 1) << 2);
149   redclash_set_stars_speed( m_star_speed);
164150}
165151
166WRITE8_HANDLER( redclash_star_reset_w )
152WRITE8_HANDLER( ladybug_state::redclash_star_reset_w )
167153{
168   redclash_set_stars_enable(space.machine(), 1);
154   redclash_set_stars_enable(1);
169155}
170156
171157TILE_GET_INFO_MEMBER(ladybug_state::get_fg_tile_info)
r20834r20835
182168   m_fg_tilemap->set_transparent_pen(0);
183169}
184170
185static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
171void ladybug_state::redclash_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
186172{
187   ladybug_state *state = machine.driver_data<ladybug_state>();
188   UINT8 *spriteram = state->m_spriteram;
173   UINT8 *spriteram = m_spriteram;
189174   int i, offs;
190175
191   for (offs = state->m_spriteram.bytes() - 0x20; offs >= 0; offs -= 0x20)
176   for (offs = m_spriteram.bytes() - 0x20; offs >= 0; offs -= 0x20)
192177   {
193178      i = 0;
194179      while (i < 0x20 && spriteram[offs + i] != 0)
r20834r20835
209194            {
210195               case 3: /* 24x24 */
211196               {
212                  int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((state->m_gfxbank & 1) << 4);
197                  int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((m_gfxbank & 1) << 4);
213198
214                  drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
199                  drawgfx_transpen(bitmap,cliprect,machine().gfx[3],
215200                        code,
216201                        color,
217202                        0,0,
218203                        sx,sy - 16,0);
219204                  /* wraparound */
220                  drawgfx_transpen(bitmap,cliprect,machine.gfx[3],
205                  drawgfx_transpen(bitmap,cliprect,machine().gfx[3],
221206                        code,
222207                        color,
223208                        0,0,
r20834r20835
228213               case 2: /* 16x16 */
229214                  if (spriteram[offs + i] & 0x20) /* zero hour spaceships */
230215                  {
231                     int code = ((spriteram[offs + i + 1] & 0xf8) >> 3) + ((state->m_gfxbank & 1) << 5);
216                     int code = ((spriteram[offs + i + 1] & 0xf8) >> 3) + ((m_gfxbank & 1) << 5);
232217                     int bank = (spriteram[offs + i + 1] & 0x02) >> 1;
233218
234                     drawgfx_transpen(bitmap,cliprect,machine.gfx[4+bank],
219                     drawgfx_transpen(bitmap,cliprect,machine().gfx[4+bank],
235220                           code,
236221                           color,
237222                           0,0,
r20834r20835
239224                  }
240225                  else
241226                  {
242                     int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((state->m_gfxbank & 1) << 4);
227                     int code = ((spriteram[offs + i + 1] & 0xf0) >> 4) + ((m_gfxbank & 1) << 4);
243228
244                     drawgfx_transpen(bitmap,cliprect,machine.gfx[2],
229                     drawgfx_transpen(bitmap,cliprect,machine().gfx[2],
245230                           code,
246231                           color,
247232                           0,0,
r20834r20835
250235                  break;
251236
252237               case 1: /* 8x8 */
253                  drawgfx_transpen(bitmap,cliprect,machine.gfx[1],
238                  drawgfx_transpen(bitmap,cliprect,machine().gfx[1],
254239                        spriteram[offs + i + 1],// + 4 * (spriteram[offs + i + 2] & 0x10),
255240                        color,
256241                        0,0,
r20834r20835
266251   }
267252}
268253
269static void draw_bullets( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
254void ladybug_state::redclash_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect )
270255{
271   ladybug_state *state = machine.driver_data<ladybug_state>();
272256   int offs;
273257
274258   for (offs = 0; offs < 0x20; offs++)
275259   {
276//      sx = state->m_videoramoffs];
277      int sx = 8 * offs + (state->m_videoram[offs] & 0x07);   /* ?? */
278      int sy = 0xff - state->m_videoram[offs + 0x20];
260//      sx = m_videoramoffs];
261      int sx = 8 * offs + (m_videoram[offs] & 0x07);   /* ?? */
262      int sy = 0xff - m_videoram[offs + 0x20];
279263
280      if (state->flip_screen())
264      if (flip_screen())
281265      {
282266         sx = 240 - sx;
283267      }
r20834r20835
301285 */
302286
303287/* This line can reset the LFSR to zero and disables the star generator */
304void redclash_set_stars_enable( running_machine &machine, UINT8 on )
305{   ladybug_state *state = machine.driver_data<ladybug_state>();
306
307   if ((state->m_stars_enable == 0) && (on == 1))
288void ladybug_state::redclash_set_stars_enable(UINT8 on)
289{   
290   if ((m_stars_enable == 0) && (on == 1))
308291   {
309      state->m_stars_offset = 0;
292      m_stars_offset = 0;
310293   }
311294
312   state->m_stars_enable = on;
295   m_stars_enable = on;
313296}
314297
315298/* This sets up which starfield to draw and the offset, */
316299/* To be called from SCREEN_VBLANK() */
317300
318void redclash_update_stars_state( running_machine &machine )
301void ladybug_state::redclash_update_stars_state()
319302{
320   ladybug_state *state = machine.driver_data<ladybug_state>();
321   if (state->m_stars_enable == 0)
303   if (m_stars_enable == 0)
322304      return;
323305
324   state->m_stars_count++;
325   state->m_stars_count %= 2;
306   m_stars_count++;
307   m_stars_count %= 2;
326308
327   if (state->m_stars_count == 0)
309   if (m_stars_count == 0)
328310   {
329      state->m_stars_offset += ((state->m_stars_speed * 2) - 0x09);
330      state->m_stars_offset %= 256 * 256;
331      state->m_stars_state = 0;
311      m_stars_offset += ((m_stars_speed * 2) - 0x09);
312      m_stars_offset %= 256 * 256;
313      m_stars_state = 0;
332314   }
333315   else
334      state->m_stars_state = 0x1fc71;
316      m_stars_state = 0x1fc71;
335317}
336318
337319/* Set the speed register (3 bits) */
r20834r20835
347329 * 7 right/up fast     (+5/2 pix per frame)
348330 */
349331
350void redclash_set_stars_speed( running_machine &machine, UINT8 speed )
332void ladybug_state::redclash_set_stars_speed(UINT8 speed )
351333{
352   ladybug_state *state = machine.driver_data<ladybug_state>();
353   state->m_stars_speed = speed;
334   m_stars_speed = speed;
354335}
355336
356337/* Draw the stars */
r20834r20835
358339/* Space Raider doesn't use the Va bit, and it is also set up to */
359340/* window the stars to a certain x range */
360341
361void redclash_draw_stars( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx )
342void ladybug_state::redclash_draw_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx )
362343{
363   ladybug_state *redclash = machine.driver_data<ladybug_state>();
364344   int i;
365345   UINT8 tempbit, feedback, star_color, xloc, yloc;
366346   UINT32 state;
367347   UINT8 hcond, vcond;
368348
369   if (redclash->m_stars_enable == 0)
349   if (m_stars_enable == 0)
370350      return;
371351
372   state = redclash->m_stars_state;
352   state = m_stars_state;
373353
374354   for(i = 0; i < 256 * 256; i++)
375355   {
376      xloc = (redclash->m_stars_offset + i) % 256;
377      yloc = ((redclash->m_stars_offset + i) /256 ) % 256;
356      xloc = (m_stars_offset + i) % 256;
357      yloc = ((m_stars_offset + i) /256 ) % 256;
378358
379359      if ((state & 0x10000) == 0)
380360         tempbit = 1;
r20834r20835
420400{
421401   // falling edge
422402   if (!state)
423      redclash_update_stars_state(machine());
403      redclash_update_stars_state();
424404}
425405
426406UINT32 ladybug_state::screen_update_redclash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
427407{
428408   bitmap.fill(get_black_pen(machine()), cliprect);
429   redclash_draw_stars(machine(), bitmap, cliprect, 0x60, 0, 0x00, 0xff);
430   ::draw_sprites(machine(), bitmap, cliprect);
431   draw_bullets(machine(), bitmap, cliprect);
409   redclash_draw_stars(bitmap, cliprect, 0x60, 0, 0x00, 0xff);
410   redclash_draw_sprites(bitmap, cliprect);
411   redclash_draw_bullets(bitmap, cliprect);
432412   m_fg_tilemap->draw(bitmap, cliprect, 0, 0);
433413   return 0;
434414}
trunk/src/mame/includes/ladybug.h
r20834r20835
8282   void screen_eof_sraider(screen_device &screen, bool state);
8383   void screen_eof_redclash(screen_device &screen, bool state);
8484   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
85};
85   DECLARE_WRITE8_MEMBER( redclash_videoram_w );
86   DECLARE_WRITE8_MEMBER( redclash_gfxbank_w );
87   DECLARE_WRITE8_MEMBER( redclash_flipscreen_w );
8688
87/*----------- defined in video/redclash.c -----------*/
89   DECLARE_WRITE8_MEMBER( redclash_star0_w );
90   DECLARE_WRITE8_MEMBER( redclash_star1_w );
91   DECLARE_WRITE8_MEMBER( redclash_star2_w );
92   DECLARE_WRITE8_MEMBER( redclash_star_reset_w );
93   DECLARE_WRITE8_MEMBER( irqack_w );
8894
89DECLARE_WRITE8_HANDLER( redclash_videoram_w );
90DECLARE_WRITE8_HANDLER( redclash_gfxbank_w );
91DECLARE_WRITE8_HANDLER( redclash_flipscreen_w );
92
93DECLARE_WRITE8_HANDLER( redclash_star0_w );
94DECLARE_WRITE8_HANDLER( redclash_star1_w );
95DECLARE_WRITE8_HANDLER( redclash_star2_w );
96DECLARE_WRITE8_HANDLER( redclash_star_reset_w );
97
98/* sraider uses the zerohour star generator board */
99void redclash_set_stars_enable(running_machine &machine, UINT8 on);
100void redclash_update_stars_state(running_machine &machine);
101void redclash_set_stars_speed(running_machine &machine, UINT8 speed);
102void redclash_draw_stars(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx);
95   /* sraider uses the zerohour star generator board */
96   void redclash_set_stars_enable(UINT8 on);
97   void redclash_update_stars_state();
98   void redclash_set_stars_speed(UINT8 speed);
99   void redclash_draw_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx);   
100   void redclash_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
101   void redclash_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect );
102};
trunk/src/mame/drivers/redclash.c
r20834r20835
2525#include "includes/ladybug.h"
2626
2727
28static WRITE8_HANDLER( irqack_w )
28WRITE8_MEMBER( ladybug_state::irqack_w )
2929{
30   ladybug_state *state = space.machine().driver_data<ladybug_state>();
31   state->m_maincpu->set_input_line(0, CLEAR_LINE);
30   m_maincpu->set_input_line(0, CLEAR_LINE);
3231}
3332
3433static ADDRESS_MAP_START( zerohour_map, AS_PROGRAM, 8, ladybug_state )
3534   AM_RANGE(0x0000, 0x2fff) AM_ROM
3635   AM_RANGE(0x3000, 0x37ff) AM_RAM
3736   AM_RANGE(0x3800, 0x3bff) AM_RAM AM_SHARE("spriteram")
38   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE_LEGACY(redclash_videoram_w) AM_SHARE("videoram")
37   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(redclash_videoram_w) AM_SHARE("videoram")
3938   AM_RANGE(0x4800, 0x4800) AM_READ_PORT("IN0")    /* IN0 */
4039   AM_RANGE(0x4801, 0x4801) AM_READ_PORT("IN1")    /* IN1 */
4140   AM_RANGE(0x4802, 0x4802) AM_READ_PORT("DSW1")   /* DSW0 */
4241   AM_RANGE(0x4803, 0x4803) AM_READ_PORT("DSW2")   /* DSW1 */
4342   AM_RANGE(0x5000, 0x5007) AM_WRITENOP    /* to sound board */
44   AM_RANGE(0x5800, 0x5800) AM_WRITE_LEGACY(redclash_star0_w)
43   AM_RANGE(0x5800, 0x5800) AM_WRITE(redclash_star0_w)
4544   AM_RANGE(0x5801, 0x5804) AM_WRITENOP    /* to sound board */
46   AM_RANGE(0x5805, 0x5805) AM_WRITE_LEGACY(redclash_star1_w)
47   AM_RANGE(0x5806, 0x5806) AM_WRITE_LEGACY(redclash_star2_w)
48   AM_RANGE(0x5807, 0x5807) AM_WRITE_LEGACY(redclash_flipscreen_w)
49   AM_RANGE(0x7000, 0x7000) AM_WRITE_LEGACY(redclash_star_reset_w)
50   AM_RANGE(0x7800, 0x7800) AM_WRITE_LEGACY(irqack_w)
45   AM_RANGE(0x5805, 0x5805) AM_WRITE(redclash_star1_w)
46   AM_RANGE(0x5806, 0x5806) AM_WRITE(redclash_star2_w)
47   AM_RANGE(0x5807, 0x5807) AM_WRITE(redclash_flipscreen_w)
48   AM_RANGE(0x7000, 0x7000) AM_WRITE(redclash_star_reset_w)
49   AM_RANGE(0x7800, 0x7800) AM_WRITE(irqack_w)
5150ADDRESS_MAP_END
5251
5352static ADDRESS_MAP_START( redclash_map, AS_PROGRAM, 8, ladybug_state )
5453   AM_RANGE(0x0000, 0x2fff) AM_ROM
5554//  AM_RANGE(0x3000, 0x3000) AM_WRITENOP
5655//  AM_RANGE(0x3800, 0x3800) AM_WRITENOP
57   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE_LEGACY(redclash_videoram_w) AM_SHARE("videoram")
56   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(redclash_videoram_w) AM_SHARE("videoram")
5857   AM_RANGE(0x4800, 0x4800) AM_READ_PORT("IN0")    /* IN0 */
5958   AM_RANGE(0x4801, 0x4801) AM_READ_PORT("IN1")    /* IN1 */
6059   AM_RANGE(0x4802, 0x4802) AM_READ_PORT("DSW1")   /* DSW0 */
6160   AM_RANGE(0x4803, 0x4803) AM_READ_PORT("DSW2")   /* DSW1 */
6261   AM_RANGE(0x5000, 0x5007) AM_WRITENOP    /* to sound board */
63   AM_RANGE(0x5800, 0x5800) AM_WRITE_LEGACY(redclash_star0_w)
64   AM_RANGE(0x5801, 0x5801) AM_WRITE_LEGACY(redclash_gfxbank_w)
65   AM_RANGE(0x5805, 0x5805) AM_WRITE_LEGACY(redclash_star1_w)
66   AM_RANGE(0x5806, 0x5806) AM_WRITE_LEGACY(redclash_star2_w)
67   AM_RANGE(0x5807, 0x5807) AM_WRITE_LEGACY(redclash_flipscreen_w)
62   AM_RANGE(0x5800, 0x5800) AM_WRITE(redclash_star0_w)
63   AM_RANGE(0x5801, 0x5801) AM_WRITE(redclash_gfxbank_w)
64   AM_RANGE(0x5805, 0x5805) AM_WRITE(redclash_star1_w)
65   AM_RANGE(0x5806, 0x5806) AM_WRITE(redclash_star2_w)
66   AM_RANGE(0x5807, 0x5807) AM_WRITE(redclash_flipscreen_w)
6867   AM_RANGE(0x6000, 0x67ff) AM_RAM
6968   AM_RANGE(0x6800, 0x6bff) AM_RAM AM_SHARE("spriteram")
70   AM_RANGE(0x7000, 0x7000) AM_WRITE_LEGACY(redclash_star_reset_w)
71   AM_RANGE(0x7800, 0x7800) AM_WRITE_LEGACY(irqack_w)
69   AM_RANGE(0x7000, 0x7000) AM_WRITE(redclash_star_reset_w)
70   AM_RANGE(0x7800, 0x7800) AM_WRITE(irqack_w)
7271ADDRESS_MAP_END
7372
7473/*

Previous 199869 Revisions Next


© 1997-2024 The MAME Team