Previous 199869 Revisions Next

r30597 Thursday 22nd May, 2014 at 16:19:39 UTC by hap
small cleanup: put draw_sprites in its own function instead of inside screen_update
[src/mame/drivers]finalizr.c
[src/mame/includes]finalizr.h
[src/mame/video]finalizr.c

trunk/src/mame/includes/finalizr.h
r30596r30597
11/***************************************************************************
22
3    Finalizer
3    Konami Finalizer
44
55***************************************************************************/
66
r30596r30597
99public:
1010   finalizr_state(const machine_config &mconfig, device_type type, const char *tag)
1111      : driver_device(mconfig, type, tag),
12      m_maincpu(*this, "maincpu"),
13      m_audiocpu(*this, "audiocpu"),
14      m_gfxdecode(*this, "gfxdecode"),
15      m_palette(*this, "palette"),
1216      m_scroll(*this, "scroll"),
1317      m_colorram(*this, "colorram"),
1418      m_videoram(*this, "videoram"),
1519      m_colorram2(*this, "colorram2"),
1620      m_videoram2(*this, "videoram2"),
1721      m_spriteram(*this, "spriteram"),
18      m_spriteram_2(*this, "spriteram_2"),
19      m_maincpu(*this, "maincpu"),
20      m_audiocpu(*this, "audiocpu"),
21      m_gfxdecode(*this, "gfxdecode"),
22      m_palette(*this, "palette")  { }
22      m_spriteram_2(*this, "spriteram_2")
23   { }
2324
25   /* devices */
26   required_device<cpu_device> m_maincpu;
27   required_device<cpu_device> m_audiocpu;
28   required_device<gfxdecode_device> m_gfxdecode;
29   required_device<palette_device> m_palette;
30
2431   /* memory pointers */
2532   required_shared_ptr<UINT8> m_scroll;
2633   required_shared_ptr<UINT8> m_colorram;
r30596r30597
3138   required_shared_ptr<UINT8> m_spriteram_2;
3239
3340   /* video-related */
34   tilemap_t       *m_fg_tilemap;
35   tilemap_t       *m_bg_tilemap;
36   int           m_spriterambank;
37   int           m_charbank;
41   tilemap_t *m_fg_tilemap;
42   tilemap_t *m_bg_tilemap;
43   int m_spriterambank;
44   int m_charbank;
3845
3946   /* misc */
40   int           m_T1_line;
41   UINT8         m_nmi_enable;
42   UINT8         m_irq_enable;
47   int m_T1_line;
48   UINT8 m_nmi_enable;
49   UINT8 m_irq_enable;
4350
44   /* devices */
4551   DECLARE_WRITE8_MEMBER(finalizr_coin_w);
4652   DECLARE_WRITE8_MEMBER(finalizr_flipscreen_w);
4753   DECLARE_WRITE8_MEMBER(finalizr_i8039_irq_w);
r30596r30597
5662   virtual void machine_reset();
5763   virtual void video_start();
5864   DECLARE_PALETTE_INIT(finalizr);
65   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
5966   UINT32 screen_update_finalizr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6067   TIMER_DEVICE_CALLBACK_MEMBER(finalizr_scanline);
61   required_device<cpu_device> m_maincpu;
62   required_device<cpu_device> m_audiocpu;
63   required_device<gfxdecode_device> m_gfxdecode;
64   required_device<palette_device> m_palette;
6568};
trunk/src/mame/video/finalizr.c
r30596r30597
11/***************************************************************************
22
3  video.c
3  Konami Finalizer
44
55  Functions to emulate the video hardware of the machine.
66
r30596r30597
119119
120120
121121
122WRITE8_MEMBER(finalizr_state::finalizr_videoctrl_w)
123{
124   m_charbank = data & 3;
125   m_spriterambank = data & 8;
126   /* other bits unknown */
127}
122/**************************************************************************/
128123
129
130
131UINT32 finalizr_state::screen_update_finalizr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
124void finalizr_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
132125{
133   int offs;
126   gfx_element *gfx1 = m_gfxdecode->gfx(1);
127   gfx_element *gfx2 = m_gfxdecode->gfx(2);
134128
135   m_bg_tilemap->mark_all_dirty();
136   m_fg_tilemap->mark_all_dirty();
129   UINT8 *sr = m_spriterambank ? m_spriteram_2 : m_spriteram;
137130
138   m_bg_tilemap->set_scrollx(0, *m_scroll - 32);
139   m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
140
141   /* Draw the sprites. */
131   for (int offs = 0; offs <= m_spriteram.bytes() - 5; offs += 5)
142132   {
143      gfx_element *gfx1 = m_gfxdecode->gfx(1);
144      gfx_element *gfx2 = m_gfxdecode->gfx(2);
133      int sx, sy, flipx, flipy, code, color, size;
145134
146      UINT8 *sr = m_spriterambank ? m_spriteram_2 : m_spriteram;
135      sx = 32 + 1 + sr[offs + 3] - ((sr[offs + 4] & 0x01) << 8);
136      sy = sr[offs + 2];
137      flipx = sr[offs + 4] & 0x20;
138      flipy = sr[offs + 4] & 0x40;
139      code = sr[offs] + ((sr[offs + 1] & 0x0f) << 8);
140      color = ((sr[offs + 1] & 0xf0) >> 4);
147141
142//      (sr[offs + 4] & 0x02) is used, meaning unknown
148143
149      for (offs = 0; offs <= m_spriteram.bytes() - 5; offs += 5)
144      size = sr[offs + 4] & 0x1c;
145
146      if (size >= 0x10)
150147      {
151         int sx, sy, flipx, flipy, code, color, size;
148         // 32x32
149         if (flip_screen())
150         {
151            sx = 256 - sx;
152            sy = 224 - sy;
153            flipx = !flipx;
154            flipy = !flipy;
155         }
152156
153
154         sx = 32 + 1 + sr[offs + 3] - ((sr[offs + 4] & 0x01) << 8);
155         sy = sr[offs + 2];
156         flipx = sr[offs + 4] & 0x20;
157         flipy = sr[offs + 4] & 0x40;
158         code = sr[offs] + ((sr[offs + 1] & 0x0f) << 8);
159         color = ((sr[offs + 1] & 0xf0)>>4);
160
161//          (sr[offs + 4] & 0x02) is used, meaning unknown
162
163         size = sr[offs + 4] & 0x1c;
164
165         if (size >= 0x10)   /* 32x32 */
157         gfx1->transpen(bitmap, cliprect, code + 0, color, flipx, flipy, flipx ? sx + 16 : sx, flipy ? sy + 16 : sy, 0);
158         gfx1->transpen(bitmap, cliprect, code + 1, color, flipx, flipy, flipx ? sx : sx + 16, flipy ? sy + 16 : sy, 0);
159         gfx1->transpen(bitmap, cliprect, code + 2, color, flipx, flipy, flipx ? sx + 16: sx , flipy ? sy : sy + 16, 0);
160         gfx1->transpen(bitmap, cliprect, code + 3, color, flipx, flipy, flipx ? sx : sx + 16, flipy ? sy : sy + 16, 0);
161      }
162      else
163      {
164         if (flip_screen())
166165         {
167            if (flip_screen())
168            {
169               sx = 256 - sx;
170               sy = 224 - sy;
171               flipx = !flipx;
172               flipy = !flipy;
173            }
166            sx = ((size & 0x08) ? 280: 272) - sx;
167            sy = ((size & 0x04) ? 248: 240) - sy;
168            flipx = !flipx;
169            flipy = !flipy;
170         }
174171
175            gfx1->transpen(bitmap,cliprect,
176                  code,
177                  color,
178                  flipx,flipy,
179                  flipx?sx+16:sx,flipy?sy+16:sy,0);
180            gfx1->transpen(bitmap,cliprect,
181                  code + 1,
182                  color,
183                  flipx,flipy,
184                  flipx?sx:sx+16,flipy?sy+16:sy,0);
185            gfx1->transpen(bitmap,cliprect,
186                  code + 2,
187                  color,
188                  flipx,flipy,
189                  flipx?sx+16:sx,flipy?sy:sy+16,0);
190            gfx1->transpen(bitmap,cliprect,
191                  code + 3,
192                  color,
193                  flipx,flipy,
194                  flipx?sx:sx+16,flipy?sy:sy+16,0);
172         if (size == 0x00)
173         {
174            // 16x16
175            gfx1->transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy, 0);
195176         }
196177         else
197178         {
198            if (flip_screen())
179            code = ((code & 0x3ff) << 2) | ((code & 0xc00) >> 10);
180
181            if (size == 0x04)
199182            {
200               sx = ((size & 0x08) ? 280:272) - sx;
201               sy = ((size & 0x04) ? 248:240) - sy;
202               flipx = !flipx;
203               flipy = !flipy;
183               // 16x8
184               gfx2->transpen(bitmap, cliprect, code &~1, color, flipx, flipy, flipx ? sx + 8 : sx, sy, 0);
185               gfx2->transpen(bitmap, cliprect, code | 1, color, flipx, flipy, flipx ? sx : sx + 8, sy, 0);
204186            }
205
206            if (size == 0x00)   /* 16x16 */
187            else if (size == 0x08)
207188            {
208               gfx1->transpen(bitmap,cliprect,
209                     code,
210                     color,
211                     flipx,flipy,
212                     sx,sy,0);
189               // 8x16
190               gfx2->transpen(bitmap, cliprect, code &~2, color, flipx, flipy, sx, flipy ? sy + 8 : sy, 0);
191               gfx2->transpen(bitmap, cliprect, code | 2, color, flipx, flipy, sx, flipy ? sy : sy + 8, 0);
213192            }
214            else
193            else if (size == 0x0c)
215194            {
216               code = ((code & 0x3ff) << 2) | ((code & 0xc00) >> 10);
217
218               if (size == 0x04)   /* 16x8 */
219               {
220                  gfx2->transpen(bitmap,cliprect,
221                        code & ~1,
222                        color,
223                        flipx,flipy,
224                        flipx?sx+8:sx,sy,0);
225                  gfx2->transpen(bitmap,cliprect,
226                        code | 1,
227                        color,
228                        flipx,flipy,
229                        flipx?sx:sx+8,sy,0);
230               }
231               else if (size == 0x08)  /* 8x16 */
232               {
233                  gfx2->transpen(bitmap,cliprect,
234                        code & ~2,
235                        color,
236                        flipx,flipy,
237                        sx,flipy?sy+8:sy,0);
238                  gfx2->transpen(bitmap,cliprect,
239                        code | 2,
240                        color,
241                        flipx,flipy,
242                        sx,flipy?sy:sy+8,0);
243               }
244               else if (size == 0x0c)  /* 8x8 */
245               {
246                  gfx2->transpen(bitmap,cliprect,
247                        code,
248                        color,
249                        flipx,flipy,
250                        sx,sy,0);
251               }
195               // 8x8
196               gfx2->transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy, 0);
252197            }
253198         }
254199      }
255200   }
201}
256202
257   {
258      const rectangle &visarea = screen.visible_area();
259      rectangle clip = cliprect;
260203
261      /* draw top status region */
262      clip.min_x = visarea.min_x;
263      clip.max_x = visarea.min_x + 31;
264      m_fg_tilemap->set_scrolldx(0,-32);
265      m_fg_tilemap->draw(screen, bitmap, clip, 0, 0);
266   }
204UINT32 finalizr_state::screen_update_finalizr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
205{
206   m_bg_tilemap->mark_all_dirty();
207   m_fg_tilemap->mark_all_dirty();
208
209   m_bg_tilemap->set_scrollx(0, *m_scroll - 32);
210   m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
211
212   draw_sprites(bitmap, cliprect);
213
214   // draw top status region
215   const rectangle &visarea = screen.visible_area();
216   rectangle clip = cliprect;
217
218   clip.min_x = visarea.min_x;
219   clip.max_x = visarea.min_x + 31;
220   m_fg_tilemap->set_scrolldx(0,-32);
221   m_fg_tilemap->draw(screen, bitmap, clip, 0, 0);
222
267223   return 0;
268224}
trunk/src/mame/drivers/finalizr.c
r30596r30597
2020#include "includes/finalizr.h"
2121
2222
23
24
2523TIMER_DEVICE_CALLBACK_MEMBER(finalizr_state::finalizr_scanline)
2624{
2725   int scanline = param;
2826
29   if(scanline == 240 && m_irq_enable) // vblank irq
27   if (scanline == 240 && m_irq_enable) // vblank irq
3028      m_maincpu->set_input_line(M6809_IRQ_LINE, HOLD_LINE);
31   else if(((scanline % 32) == 0) && m_nmi_enable) // timer irq
29   else if (((scanline % 32) == 0) && m_nmi_enable) // timer irq
3230      m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
3331}
3432
3533
34WRITE8_MEMBER(finalizr_state::finalizr_videoctrl_w)
35{
36   m_charbank = data & 3;
37   m_spriterambank = data & 8;
38   /* other bits unknown */
39}
40
3641WRITE8_MEMBER(finalizr_state::finalizr_coin_w)
3742{
3843   coin_counter_w(machine(), 0, data & 0x01);
r30596r30597
257262   MCFG_CPU_PROGRAM_MAP(main_map)
258263   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", finalizr_state, finalizr_scanline, "screen", 0, 1)
259264
260   MCFG_CPU_ADD("audiocpu", I8039,XTAL_18_432MHz/2)    /* 9.216MHz clkin ?? */
265   MCFG_CPU_ADD("audiocpu", I8039,XTAL_18_432MHz/2) /* 9.216MHz clkin ?? */
261266   MCFG_CPU_PROGRAM_MAP(sound_map)
262267   MCFG_CPU_IO_MAP(sound_io_map)
263268
264
265269   /* video hardware */
266270   MCFG_SCREEN_ADD("screen", RASTER)
267271   MCFG_SCREEN_REFRESH_RATE(60)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team