Previous 199869 Revisions Next

r33402 Saturday 15th November, 2014 at 07:10:51 UTC by Vasantha Crabb
Make prehisle use proper priority rather than two-pass sprite rendering, clean up a little
[src/mame/drivers]prehisle.c
[src/mame/includes]prehisle.h
[src/mame/video]prehisle.c

trunk/src/mame/drivers/prehisle.c
r241913r241914
100100   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )  PORT_DIPLOCATION("SW1:1")
101101   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
102102   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
103   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Level_Select ) )     PORT_DIPLOCATION("SW1:2")
103   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Level_Select ) ) PORT_DIPLOCATION("SW1:2")
104104   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
105105   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
106106   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW1:3")
r241913r241914
126126   PORT_DIPSETTING(    0x03, DEF_STR( Standard ) )
127127   PORT_DIPSETTING(    0x01, "Middle" )
128128   PORT_DIPSETTING(    0x00, DEF_STR( Difficult ) )
129   PORT_DIPNAME( 0x0c, 0x0c, "Game Mode" )         PORT_DIPLOCATION("SW2:3,4")
129   PORT_DIPNAME( 0x0c, 0x0c, "Game Mode" )             PORT_DIPLOCATION("SW2:3,4")
130130   PORT_DIPSETTING(    0x08, "Demo Sounds Off" )
131131   PORT_DIPSETTING(    0x0c, "Demo Sounds On" )
132132   PORT_DIPSETTING(    0x00, "Freeze" )
r241913r241914
136136   PORT_DIPSETTING(    0x20, "150K 300K" )
137137   PORT_DIPSETTING(    0x10, "300K 500K" )
138138   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
139   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )   PORT_DIPLOCATION("SW2:7")
139   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SW2:7")
140140   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
141141   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
142142   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")
trunk/src/mame/includes/prehisle.h
r241913r241914
2323   tilemap_t *m_bg2_tilemap;
2424   tilemap_t *m_bg_tilemap;
2525   tilemap_t *m_fg_tilemap;
26
2627   DECLARE_WRITE16_MEMBER(prehisle_sound16_w);
2728   DECLARE_WRITE16_MEMBER(prehisle_bg_videoram16_w);
2829   DECLARE_WRITE16_MEMBER(prehisle_fg_videoram16_w);
r241913r241914
3536   TILE_GET_INFO_MEMBER(get_fg_tile_info);
3637   virtual void video_start();
3738   UINT32 screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
38   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int foreground );
39   void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3940   DECLARE_WRITE_LINE_MEMBER(irqhandler);
41
4042   required_device<cpu_device> m_maincpu;
4143   required_device<cpu_device> m_audiocpu;
4244   required_device<upd7759_device> m_upd7759;
trunk/src/mame/video/prehisle.c
r241913r241914
2727   switch (offset)
2828   {
2929   case 0x08: return ioport("P2")->read();                     // Player 2
30   case 0x10: return ioport("COIN")->read();                       // Coins, Tilt, Service
31   case 0x20: return ioport("P1")->read() ^ m_invert_controls;     // Player 1
32   case 0x21: return ioport("DSW0")->read();                       // DIPs
33   case 0x22: return ioport("DSW1")->read();                       // DIPs + VBLANK
30   case 0x10: return ioport("COIN")->read();                   // Coins, Tilt, Service
31   case 0x20: return ioport("P1")->read() ^ m_invert_controls; // Player 1
32   case 0x21: return ioport("DSW0")->read();                   // DIPs
33   case 0x22: return ioport("DSW1")->read();                   // DIPs + VBLANK
3434   default: return 0;
3535   }
3636}
r241913r241914
5454   }
5555}
5656
57/* tile layout
580  xxxx....  color
590  ....x...  flip x
600  .....xxx  gfx code high bits
611  xxxxxxxx  gfx code low bits
62*/
5763TILE_GET_INFO_MEMBER(prehisle_state::get_bg2_tile_info)
5864{
59   UINT8 *tilerom = memregion("gfx5")->base();
65   UINT8 const *const tilerom = memregion("gfx5")->base();
6066
61   int offs = tile_index * 2;
62   int attr = tilerom[offs + 1] + (tilerom[offs] << 8);
63   int code = (attr & 0x7ff) | 0x800;
64   int color = attr >> 12;
65   int flags = (attr & 0x800) ? TILE_FLIPX : 0;
67   int const offs = tile_index * 2;
68   int const attr = tilerom[offs + 1] + (tilerom[offs] << 8);
69   int const code = (attr & 0x7ff) | 0x800;
70   int const color = attr >> 12;
71   int const flags = (attr & 0x800) ? TILE_FLIPX : 0;
6672
6773   SET_TILE_INFO_MEMBER(1, code, color, flags);
6874}
6975
76/* tile layout
770  xxxx.... ........  color
780  ....x... ........  flip y
790  .....xxx xxxxxxxx  gfx code
80*/
7081TILE_GET_INFO_MEMBER(prehisle_state::get_bg_tile_info)
7182{
72   int attr = m_bg_videoram16[tile_index];
73   int code = attr & 0x7ff;
74   int color = attr >> 12;
75   int flags = (attr & 0x800) ? TILE_FLIPY : 0;
83   int const attr = m_bg_videoram16[tile_index];
84   int const code = attr & 0x7ff;
85   int const color = attr >> 12;
86   int const flags = (attr & 0x800) ? TILE_FLIPY : 0;
7687
7788   SET_TILE_INFO_MEMBER(2, code, color, flags);
7889}
7990
91/* tile layout
920  xxxx.... ........  color
930  ....xxxx xxxxxxxx  gfx code
94*/
8095TILE_GET_INFO_MEMBER(prehisle_state::get_fg_tile_info)
8196{
82   int attr = m_videoram[tile_index];
83   int code = attr & 0xfff;
84   int color = attr >> 12;
97   int const attr = m_videoram[tile_index];
98   int const code = attr & 0xfff;
99   int const color = attr >> 12;
85100
86101   SET_TILE_INFO_MEMBER(0, code, color, 0);
87102}
88103
89104void prehisle_state::video_start()
90105{
91   m_bg2_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(prehisle_state::get_bg2_tile_info),this), TILEMAP_SCAN_COLS,
92         16, 16, 1024, 32);
106   // ROM-based background layer
107   m_bg2_tilemap = &machine().tilemap().create(
108         m_gfxdecode,
109         tilemap_get_info_delegate(FUNC(prehisle_state::get_bg2_tile_info), this),
110         TILEMAP_SCAN_COLS,      // scan order
111         16, 16,                 // tile size
112         1024, 32);              // tilemap size
93113
94   m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(prehisle_state::get_bg_tile_info),this), TILEMAP_SCAN_COLS,
95         16, 16, 256, 32);
114   // RAM-based background layer (overlays most sprites)
115   m_bg_tilemap = &machine().tilemap().create(
116         m_gfxdecode,
117         tilemap_get_info_delegate(FUNC(prehisle_state::get_bg_tile_info), this),
118         TILEMAP_SCAN_COLS,      // scan order
119         16, 16,                 // tile size
120         256, 32);               // tilemap size
121   m_bg_tilemap->set_transparent_pen(15);
96122
97   m_fg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(prehisle_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS,
98         8, 8, 32, 32);
99
100   m_bg_tilemap->set_transparent_pen(15);
123   // text layer
124   m_fg_tilemap = &machine().tilemap().create(
125         m_gfxdecode,
126         tilemap_get_info_delegate(FUNC(prehisle_state::get_fg_tile_info), this),
127         TILEMAP_SCAN_ROWS,      // scan order
128         8, 8,                   // tile size
129         32, 32);                // tilemap size
101130   m_fg_tilemap->set_transparent_pen(15);
102131
103132   /* register for saving */
r241913r241914
105134}
106135
107136/* sprite layout
108o fedcba9876543210
109137
1100 .......xxxxxxxxx y, other bits unused?
1111 .......xxxxxxxxx x, other bits unused?
112
1132 ...xxxxxxxxxxxxx code
1142 ..x............. ?
1152 .x.............. flipx
1162 x............... flipy
117
1183 xxxx............ color+priority, other bits unknown
1380  .......x xxxxxxxx  y, other bits unused?
1391  .......x xxxxxxxx  x, other bits unused?
1402  x....... ........  flip y
1412  .x...... ........  flip x
1422  ..x..... ........  ?
1432  ...xxxxx xxxxxxxx  gfx code
1443  xxxx.... ........  color+priority, other bits unknown
119145*/
120void prehisle_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int foreground )
146void prehisle_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
121147{
122   UINT16 *spriteram16 = m_spriteram;
123   int offs;
148   UINT16 const *const spriteram16 = m_spriteram;
124149
125   for (offs = 0; offs < 1024; offs += 4)
150   for (int offs = 0; offs < 1024; offs += 4)
126151   {
127      int attr = spriteram16[offs + 2];
128      int code = attr & 0x1fff;
129      int color = spriteram16[offs + 3] >> 12;
130      int priority = (color < 0x4); // correct?
131      int flipx = attr & 0x4000;
132      int flipy = attr & 0x8000;
133      int sx = spriteram16[offs + 1]&0x1ff;
134      int sy = spriteram16[offs]&0x1ff;
152      int const attr = spriteram16[offs + 2];
153      int const code = attr & 0x1fff;
154      int const color = spriteram16[offs + 3] >> 12;
155      int const priority = (color < 0x4) ? 0x04 : 0x06;
156      bool flipx = attr & 0x4000;
157      bool flipy = attr & 0x8000;
158      int sx = spriteram16[offs + 1] & 0x1ff;
159      int sy = spriteram16[offs] & 0x1ff;
135160
136161      // coordinates are 9-bit signed
137      if (sx&0x100) sx=-0x100+(sx&0xff);
138      if (sy&0x100) sy=-0x100+(sy&0xff);
162      if (sx & 0x100) sx = -0x100 + (sx & 0xff);
163      if (sy & 0x100) sy = -0x100 + (sy & 0xff);
139164
140165      if (flip_screen())
141166      {
r241913r241914
145170         flipy = !flipy;
146171      }
147172
148      if ((foreground && priority) || (!foreground && !priority))
149      {
150         m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, code, color, flipx, flipy, sx, sy, 15);
151      }
173      m_gfxdecode->gfx(3)->prio_transpen(
174         bitmap, cliprect,
175         code, color,
176         flipx, flipy,
177         sx, sy,
178         screen.priority(), priority,
179         15); // transparent pen
152180   }
153181}
154182
155183UINT32 prehisle_state::screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
156184{
185   screen.priority().fill(0, cliprect);
186
157187   m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 0);
158   draw_sprites(bitmap, cliprect, 0);
159   m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
160   draw_sprites(bitmap, cliprect, 1);
161   m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
188   m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 1);
189   m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 2);
190   draw_sprites(screen, bitmap, cliprect);
191
162192   return 0;
163193}


Previous 199869 Revisions Next


© 1997-2024 The MAME Team