trunk/src/mame/includes/finalizr.h
| r30596 | r30597 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | Finalizer |
| 3 | Konami Finalizer |
| 4 | 4 | |
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 | |
| r30596 | r30597 | |
| 9 | 9 | public: |
| 10 | 10 | finalizr_state(const machine_config &mconfig, device_type type, const char *tag) |
| 11 | 11 | : 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"), |
| 12 | 16 | m_scroll(*this, "scroll"), |
| 13 | 17 | m_colorram(*this, "colorram"), |
| 14 | 18 | m_videoram(*this, "videoram"), |
| 15 | 19 | m_colorram2(*this, "colorram2"), |
| 16 | 20 | m_videoram2(*this, "videoram2"), |
| 17 | 21 | 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 | { } |
| 23 | 24 | |
| 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 | |
| 24 | 31 | /* memory pointers */ |
| 25 | 32 | required_shared_ptr<UINT8> m_scroll; |
| 26 | 33 | required_shared_ptr<UINT8> m_colorram; |
| r30596 | r30597 | |
| 31 | 38 | required_shared_ptr<UINT8> m_spriteram_2; |
| 32 | 39 | |
| 33 | 40 | /* 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; |
| 38 | 45 | |
| 39 | 46 | /* 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; |
| 43 | 50 | |
| 44 | | /* devices */ |
| 45 | 51 | DECLARE_WRITE8_MEMBER(finalizr_coin_w); |
| 46 | 52 | DECLARE_WRITE8_MEMBER(finalizr_flipscreen_w); |
| 47 | 53 | DECLARE_WRITE8_MEMBER(finalizr_i8039_irq_w); |
| r30596 | r30597 | |
| 56 | 62 | virtual void machine_reset(); |
| 57 | 63 | virtual void video_start(); |
| 58 | 64 | DECLARE_PALETTE_INIT(finalizr); |
| 65 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 59 | 66 | UINT32 screen_update_finalizr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 60 | 67 | 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; |
| 65 | 68 | }; |
trunk/src/mame/video/finalizr.c
| r30596 | r30597 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | video.c |
| 3 | Konami Finalizer |
| 4 | 4 | |
| 5 | 5 | Functions to emulate the video hardware of the machine. |
| 6 | 6 | |
| r30596 | r30597 | |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | |
| 122 | | WRITE8_MEMBER(finalizr_state::finalizr_videoctrl_w) |
| 123 | | { |
| 124 | | m_charbank = data & 3; |
| 125 | | m_spriterambank = data & 8; |
| 126 | | /* other bits unknown */ |
| 127 | | } |
| 122 | /**************************************************************************/ |
| 128 | 123 | |
| 129 | | |
| 130 | | |
| 131 | | UINT32 finalizr_state::screen_update_finalizr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 124 | void finalizr_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 132 | 125 | { |
| 133 | | int offs; |
| 126 | gfx_element *gfx1 = m_gfxdecode->gfx(1); |
| 127 | gfx_element *gfx2 = m_gfxdecode->gfx(2); |
| 134 | 128 | |
| 135 | | m_bg_tilemap->mark_all_dirty(); |
| 136 | | m_fg_tilemap->mark_all_dirty(); |
| 129 | UINT8 *sr = m_spriterambank ? m_spriteram_2 : m_spriteram; |
| 137 | 130 | |
| 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) |
| 142 | 132 | { |
| 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; |
| 145 | 134 | |
| 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); |
| 147 | 141 | |
| 142 | // (sr[offs + 4] & 0x02) is used, meaning unknown |
| 148 | 143 | |
| 149 | | for (offs = 0; offs <= m_spriteram.bytes() - 5; offs += 5) |
| 144 | size = sr[offs + 4] & 0x1c; |
| 145 | |
| 146 | if (size >= 0x10) |
| 150 | 147 | { |
| 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 | } |
| 152 | 156 | |
| 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()) |
| 166 | 165 | { |
| 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 | } |
| 174 | 171 | |
| 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); |
| 195 | 176 | } |
| 196 | 177 | else |
| 197 | 178 | { |
| 198 | | if (flip_screen()) |
| 179 | code = ((code & 0x3ff) << 2) | ((code & 0xc00) >> 10); |
| 180 | |
| 181 | if (size == 0x04) |
| 199 | 182 | { |
| 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); |
| 204 | 186 | } |
| 205 | | |
| 206 | | if (size == 0x00) /* 16x16 */ |
| 187 | else if (size == 0x08) |
| 207 | 188 | { |
| 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); |
| 213 | 192 | } |
| 214 | | else |
| 193 | else if (size == 0x0c) |
| 215 | 194 | { |
| 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); |
| 252 | 197 | } |
| 253 | 198 | } |
| 254 | 199 | } |
| 255 | 200 | } |
| 201 | } |
| 256 | 202 | |
| 257 | | { |
| 258 | | const rectangle &visarea = screen.visible_area(); |
| 259 | | rectangle clip = cliprect; |
| 260 | 203 | |
| 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 | | } |
| 204 | UINT32 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 | |
| 267 | 223 | return 0; |
| 268 | 224 | } |