trunk/src/mame/drivers/mario.c
r32744 | r32745 | |
303 | 303 | static INPUT_PORTS_START( mariobl ) |
304 | 304 | |
305 | 305 | PORT_START("SYSTEM") |
306 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) |
| 306 | PORT_SERVICE_NO_TOGGLE( 0x01, IP_ACTIVE_LOW ) |
307 | 307 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
308 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL |
| 308 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
309 | 309 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
310 | 310 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 ) |
311 | 311 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) |
r32744 | r32745 | |
313 | 313 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) |
314 | 314 | |
315 | 315 | PORT_START("INPUTS") |
316 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY |
317 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY |
| 316 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 317 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
318 | 318 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY |
319 | 319 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY |
320 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL |
321 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL |
| 320 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 321 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
322 | 322 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL |
323 | 323 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL |
324 | 324 | |
trunk/src/mame/video/mario.c
r32744 | r32745 | |
147 | 147 | * confirmed on mametests.org as being present on real PCB as well. |
148 | 148 | */ |
149 | 149 | |
150 | | void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int yaddr, int xaddr, int dx, int dy) |
| 150 | void mario_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int is_bootleg) |
151 | 151 | { |
152 | 152 | /* TODO: draw_sprites should adopt the scanline logic from dkong.c |
153 | 153 | * The schematics have the same logic for sprite buffering. |
154 | 154 | */ |
155 | 155 | int offs; |
156 | 156 | |
157 | | for (offs = 0; offs < m_spriteram.bytes(); offs += 4) |
| 157 | int start, end, inc; |
| 158 | |
| 159 | if (!is_bootleg) |
158 | 160 | { |
159 | | if (m_spriteram[offs]) |
| 161 | start = 0; |
| 162 | end = m_spriteram.bytes(); |
| 163 | inc = 4; |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | start = m_spriteram.bytes()-4; |
| 168 | end = -4; |
| 169 | inc = -4; |
| 170 | } |
| 171 | |
| 172 | offs = start; |
| 173 | |
| 174 | while (offs != end) |
| 175 | { |
| 176 | if (is_bootleg || m_spriteram[offs]) |
160 | 177 | { |
161 | 178 | int x, y; |
| 179 | int code, color, flipx, flipy; |
162 | 180 | |
163 | | // from schematics .... |
164 | | y = (m_spriteram[offs+yaddr] + (m_flip ? 0xF7 : 0xF9) + 1) & 0xFF; |
165 | | x = m_spriteram[offs+xaddr]; |
166 | | // sprite will be drawn if (y + scanline) & 0xF0 = 0xF0 |
167 | | y = 240 - y; /* logical screen position */ |
| 181 | if (!is_bootleg) |
| 182 | { |
| 183 | // from schematics .... |
| 184 | y = (m_spriteram[offs + 0] + (m_flip ? 0xF7 : 0xF9) + 1) & 0xFF; |
| 185 | x = m_spriteram[offs + 3]; |
| 186 | // sprite will be drawn if (y + scanline) & 0xF0 = 0xF0 |
| 187 | y = 240 - y; /* logical screen position */ |
168 | 188 | |
169 | | y = y ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ |
170 | | x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ |
| 189 | y = y ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ |
| 190 | x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ |
| 191 | |
| 192 | code = m_spriteram[offs + 2]; |
| 193 | color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor; |
| 194 | flipx = (m_spriteram[offs + 1] & 0x80); |
| 195 | flipy = (m_spriteram[offs + 1] & 0x40); |
171 | 196 | |
| 197 | if (m_flip) |
| 198 | { |
| 199 | y -= 14; |
| 200 | x -= 7; |
| 201 | } |
| 202 | else |
| 203 | { |
| 204 | y += 1; |
| 205 | x -= 8; |
| 206 | } |
| 207 | } |
| 208 | else |
| 209 | { |
| 210 | y = (m_spriteram[offs + 3] + (m_flip ? 0xF7 : 0xF9) + 1) & 0xFF; |
| 211 | x = m_spriteram[offs + 0]; |
| 212 | y = 240 - y; /* logical screen position */ |
| 213 | |
| 214 | // y = y ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ |
| 215 | // x = x ^ (m_flip ? 0xFF : 0x00); /* physical screen location */ |
| 216 | |
| 217 | code = (m_spriteram[offs + 2] & 0x7f) | ((m_spriteram[offs + 1] & 0x40) << 1); // upper tile bit is where the flipy bit goes on mario |
| 218 | color = (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor; |
| 219 | flipx = (m_spriteram[offs + 1] & 0x80); |
| 220 | flipy = (m_spriteram[offs + 2] & 0x80); // and the flipy bit is where the upper tile bit is on mario |
| 221 | |
| 222 | y += -7; |
| 223 | } |
| 224 | |
172 | 225 | if (m_flip) |
173 | 226 | { |
174 | | y -= 14; |
175 | | x -= 7; |
176 | | m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, |
177 | | m_spriteram[offs + 2], |
178 | | (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor, |
179 | | !(m_spriteram[offs + 1] & 0x80),!(m_spriteram[offs + 1] & 0x40), |
180 | | x+dx, y+dy,0); |
| 227 | m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, |
| 228 | code, |
| 229 | color, |
| 230 | !flipx, !flipy, |
| 231 | x, y, 0); |
181 | 232 | } |
182 | 233 | else |
183 | 234 | { |
184 | | y += 1; |
185 | | x -= 8; |
186 | | m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, |
187 | | m_spriteram[offs + 2], |
188 | | (m_spriteram[offs + 1] & 0x0f) + 16 * m_palette_bank + 32 * m_monitor, |
189 | | (m_spriteram[offs + 1] & 0x80),(m_spriteram[offs + 1] & 0x40), |
190 | | x+dx, y+dy,0); |
| 235 | |
| 236 | m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, |
| 237 | code, |
| 238 | color, |
| 239 | flipx, flipy, |
| 240 | x, y, 0); |
191 | 241 | } |
192 | 242 | } |
| 243 | |
| 244 | offs += inc; |
193 | 245 | } |
194 | 246 | } |
195 | 247 | |
r32744 | r32745 | |
214 | 266 | UINT32 mario_state::screen_update_mario(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
215 | 267 | { |
216 | 268 | screen_update_common(screen, bitmap, cliprect); |
217 | | draw_sprites(bitmap, cliprect, 0, 3, 0, 0); |
| 269 | draw_sprites(bitmap, cliprect, 0); |
218 | 270 | return 0; |
219 | 271 | } |
220 | 272 | |
r32744 | r32745 | |
226 | 278 | |
227 | 279 | |
228 | 280 | screen_update_common(screen, bitmap, cliprect); |
229 | | draw_sprites(bitmap, cliprect, 3, 0, 8, -8); |
| 281 | draw_sprites(bitmap, cliprect, 1); |
230 | 282 | return 0; |
231 | 283 | } |