1 // license:BSD-3-Clause
2 // copyright-holders:Mike Balfour
3 /***************************************************************************
4
5 Atari Basketball hardware
6
7 ***************************************************************************/
8
9 #include "emu.h"
10 #include "includes/bsktball.h"
11
12
bsktball_videoram_w(offs_t offset,uint8_t data)13 void bsktball_state::bsktball_videoram_w(offs_t offset, uint8_t data)
14 {
15 m_videoram[offset] = data;
16 m_bg_tilemap->mark_tile_dirty(offset);
17 }
18
TILE_GET_INFO_MEMBER(bsktball_state::get_bg_tile_info)19 TILE_GET_INFO_MEMBER(bsktball_state::get_bg_tile_info)
20 {
21 int attr = m_videoram[tile_index];
22 int code = ((attr & 0x0f) << 2) | ((attr & 0x30) >> 4);
23 int color = (attr & 0x40) >> 6;
24 int flags = (attr & 0x80) ? TILE_FLIPX : 0;
25
26 tileinfo.set(0, code, color, flags);
27 }
28
video_start()29 void bsktball_state::video_start()
30 {
31 m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(bsktball_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
32 }
33
draw_sprites(bitmap_ind16 & bitmap,const rectangle & cliprect)34 void bsktball_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
35 {
36 for (int mot = 0; mot < 16; mot++)
37 {
38 int pic = m_motion[mot * 4];
39 int sy = 224 - m_motion[mot * 4 + 1];
40 int sx = m_motion[mot * 4 + 2];
41 int color = m_motion[mot * 4 + 3];
42 int flipx = (pic & 0x80) >> 7;
43
44 pic = (pic & 0x3f);
45 color = (color & 0x3f);
46
47 m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, pic, color, flipx, 0, sx, sy, 0);
48 }
49 }
50
screen_update_bsktball(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)51 uint32_t bsktball_state::screen_update_bsktball(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
52 {
53 m_bg_tilemap->draw(screen, bitmap, cliprect, 0);
54 draw_sprites(bitmap, cliprect);
55 return 0;
56 }
57