trunk/src/mame/drivers/3x3puzzl.c
r24761 | r24762 | |
52 | 52 | required_shared_ptr<UINT16> m_videoram2; |
53 | 53 | required_shared_ptr<UINT16> m_videoram3; |
54 | 54 | |
| 55 | UINT16 m_videoram1_buffer[0x800/2]; |
| 56 | UINT16 m_videoram2_buffer[0x1000/2]; |
| 57 | UINT16 m_videoram3_buffer[0x1000/2]; |
| 58 | |
55 | 59 | // devices |
56 | 60 | required_device<cpu_device> m_maincpu; |
57 | 61 | required_device<okim6295_device> m_oki; |
58 | 62 | |
59 | 63 | // screen updates |
60 | | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 64 | UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
61 | 65 | |
62 | 66 | /* video-related */ |
63 | 67 | tilemap_t *m_tilemap1; |
64 | 68 | tilemap_t *m_tilemap2; |
65 | 69 | tilemap_t *m_tilemap3; |
66 | 70 | |
67 | | DECLARE_WRITE16_MEMBER(videoram1_w); |
68 | 71 | TILE_GET_INFO_MEMBER(get_tile1_info); |
69 | | DECLARE_WRITE16_MEMBER(videoram2_w); |
70 | 72 | TILE_GET_INFO_MEMBER(get_tile2_info); |
71 | | DECLARE_WRITE16_MEMBER(videoram3_w); |
72 | 73 | TILE_GET_INFO_MEMBER(get_tile3_info); |
73 | 74 | |
74 | 75 | int m_oki_bank; |
| 76 | UINT16 m_gfx_control; |
75 | 77 | |
76 | 78 | DECLARE_WRITE16_HANDLER(gfx_ctrl_w); |
77 | 79 | DECLARE_WRITE16_HANDLER(tilemap1_scrollx_w); |
78 | 80 | DECLARE_WRITE16_HANDLER(tilemap1_scrolly_w); |
79 | 81 | |
80 | | |
81 | 82 | protected: |
82 | 83 | virtual void video_start(); |
83 | 84 | virtual void machine_start(); |
84 | 85 | virtual void machine_reset(); |
85 | 86 | }; |
86 | 87 | |
87 | | WRITE16_MEMBER(_3x3puzzle_state::videoram1_w) |
88 | | { |
89 | | COMBINE_DATA(&m_videoram1[offset]); |
90 | | m_tilemap1->mark_tile_dirty(offset); |
91 | | } |
92 | 88 | |
| 89 | |
93 | 90 | TILE_GET_INFO_MEMBER(_3x3puzzle_state::get_tile1_info) |
94 | 91 | { |
95 | | UINT16 code = m_videoram1[tile_index]; |
| 92 | UINT16 code = m_videoram1_buffer[tile_index]; |
96 | 93 | SET_TILE_INFO_MEMBER( |
97 | 94 | 0, |
98 | 95 | code, |
r24761 | r24762 | |
100 | 97 | 0); |
101 | 98 | } |
102 | 99 | |
103 | | WRITE16_MEMBER(_3x3puzzle_state::videoram2_w) |
104 | | { |
105 | | COMBINE_DATA(&m_videoram2[offset]); |
106 | | m_tilemap2->mark_tile_dirty(offset); |
107 | | } |
108 | | |
109 | 100 | TILE_GET_INFO_MEMBER(_3x3puzzle_state::get_tile2_info) |
110 | 101 | { |
111 | | UINT16 code = m_videoram2[tile_index]; |
| 102 | UINT16 code = m_videoram2_buffer[tile_index]; |
112 | 103 | SET_TILE_INFO_MEMBER( |
113 | 104 | 1, |
114 | 105 | code, |
r24761 | r24762 | |
116 | 107 | 0); |
117 | 108 | } |
118 | 109 | |
119 | | WRITE16_MEMBER(_3x3puzzle_state::videoram3_w) |
120 | | { |
121 | | COMBINE_DATA(&m_videoram3[offset]); |
122 | | m_tilemap3->mark_tile_dirty(offset); |
123 | | } |
124 | | |
125 | 110 | TILE_GET_INFO_MEMBER(_3x3puzzle_state::get_tile3_info) |
126 | 111 | { |
127 | | UINT16 code = m_videoram3[tile_index]; |
| 112 | UINT16 code = m_videoram3_buffer[tile_index]; |
128 | 113 | SET_TILE_INFO_MEMBER( |
129 | 114 | 2, |
130 | 115 | code, |
r24761 | r24762 | |
144 | 129 | // bit 0 (0x01) set in Casanova intro (could be OKI bank instead of bit 2?) |
145 | 130 | |
146 | 131 | //printf("%04x\n",data&0xc7); |
| 132 | COMBINE_DATA(&m_gfx_control); |
147 | 133 | |
148 | 134 | if ( BIT(data,4) ) |
149 | 135 | { |
r24761 | r24762 | |
180 | 166 | m_tilemap3->set_transparent_pen(0); |
181 | 167 | } |
182 | 168 | |
183 | | UINT32 _3x3puzzle_state::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 169 | UINT32 _3x3puzzle_state::screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
184 | 170 | { |
| 171 | |
| 172 | |
185 | 173 | m_tilemap1->draw(screen, bitmap, cliprect, 0, 1); |
186 | 174 | m_tilemap2->draw(screen, bitmap, cliprect, 0, 2); |
187 | 175 | m_tilemap3->draw(screen, bitmap, cliprect, 0, 3); |
| 176 | |
| 177 | // guess based on register use and Casanova intro |
| 178 | if (m_gfx_control&0x20) |
| 179 | { |
| 180 | for (int offset=0;offset<0x800/2;offset++) |
| 181 | { |
| 182 | m_videoram1_buffer[offset] = m_videoram1[offset]; |
| 183 | m_tilemap1->mark_tile_dirty(offset); |
| 184 | } |
| 185 | |
| 186 | for (int offset=0;offset<0x1000/2;offset++) |
| 187 | { |
| 188 | m_videoram2_buffer[offset] = m_videoram2[offset]; |
| 189 | m_tilemap2->mark_tile_dirty(offset); |
| 190 | m_videoram3_buffer[offset] = m_videoram3[offset]; |
| 191 | m_tilemap3->mark_tile_dirty(offset); |
| 192 | } |
| 193 | } |
| 194 | |
188 | 195 | return 0; |
189 | 196 | } |
190 | 197 | |
191 | 198 | static ADDRESS_MAP_START( _3x3puzzle_map, AS_PROGRAM, 16, _3x3puzzle_state ) |
192 | 199 | AM_RANGE(0x000000, 0x07ffff) AM_ROM |
193 | 200 | AM_RANGE(0x100000, 0x10ffff) AM_RAM |
194 | | AM_RANGE(0x200000, 0x2007ff) AM_WRITE(videoram1_w) AM_SHARE("videoram1") |
195 | | AM_RANGE(0x201000, 0x201fff) AM_WRITE(videoram2_w) AM_SHARE("videoram2") |
196 | | AM_RANGE(0x202000, 0x202fff) AM_WRITE(videoram3_w) AM_SHARE("videoram3") |
| 201 | AM_RANGE(0x200000, 0x2007ff) AM_RAM AM_SHARE("videoram1") |
| 202 | AM_RANGE(0x201000, 0x201fff) AM_RAM AM_SHARE("videoram2") |
| 203 | AM_RANGE(0x202000, 0x202fff) AM_RAM AM_SHARE("videoram3") |
197 | 204 | AM_RANGE(0x280000, 0x280001) AM_READ_PORT("VBLANK") |
198 | 205 | AM_RANGE(0x300000, 0x3005ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_word_w) AM_SHARE("paletteram") |
199 | 206 | AM_RANGE(0x400000, 0x400001) AM_WRITE(tilemap1_scrollx_w) |