trunk/src/mame/drivers/supduck.c
| r242044 | r242045 | |
| 13 | 13 | #include "cpu/z80/z80.h" |
| 14 | 14 | #include "cpu/m68000/m68000.h" |
| 15 | 15 | #include "sound/okim6295.h" |
| 16 | #include "video/bufsprite.h" |
| 16 | 17 | |
| 17 | | |
| 18 | 18 | class supduck_state : public driver_device |
| 19 | 19 | { |
| 20 | 20 | public: |
| r242044 | r242045 | |
| 22 | 22 | : driver_device(mconfig, type, tag), |
| 23 | 23 | m_maincpu(*this, "maincpu"), |
| 24 | 24 | m_audiocpu(*this, "audiocpu"), |
| 25 | m_spriteram(*this, "spriteram") , |
| 25 | 26 | m_tx_videoram(*this, "txvideoram"), |
| 26 | | m_gfxdecode(*this, "gfxdecode") |
| 27 | m_gfxdecode(*this, "gfxdecode"), |
| 28 | m_palette(*this, "palette") |
| 27 | 29 | { } |
| 28 | 30 | |
| 29 | 31 | // devices |
| r242044 | r242045 | |
| 31 | 33 | required_device<z80_device> m_audiocpu; |
| 32 | 34 | |
| 33 | 35 | // shared pointers |
| 36 | required_device<buffered_spriteram16_device> m_spriteram; |
| 34 | 37 | required_shared_ptr<UINT16> m_tx_videoram; |
| 35 | 38 | |
| 36 | 39 | required_device<gfxdecode_device> m_gfxdecode; |
| 40 | required_device<palette_device> m_palette; |
| 37 | 41 | |
| 38 | 42 | tilemap_t *m_tx_tilemap; |
| 39 | 43 | |
| r242044 | r242045 | |
| 49 | 53 | |
| 50 | 54 | virtual void video_start(); |
| 51 | 55 | |
| 56 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority); |
| 52 | 57 | TILE_GET_INFO_MEMBER(get_tx_tile_info); |
| 53 | 58 | }; |
| 54 | 59 | |
| 55 | 60 | void supduck_state::video_start() |
| 56 | 61 | { |
| 57 | 62 | m_tx_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(supduck_state::get_tx_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); |
| 63 | m_tx_tilemap->set_transparent_pen(3); |
| 64 | |
| 58 | 65 | } |
| 59 | 66 | |
| 60 | 67 | UINT32 supduck_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 61 | 68 | { |
| 69 | bitmap.fill(m_palette->black_pen(), cliprect); |
| 70 | |
| 71 | draw_sprites(bitmap, cliprect, 0); |
| 72 | draw_sprites(bitmap, cliprect, 1); //draw priority sprites? |
| 73 | |
| 62 | 74 | m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 63 | 75 | return 0; |
| 64 | 76 | } |
| r242044 | r242045 | |
| 70 | 82 | m_tx_tilemap->mark_tile_dirty(offset); |
| 71 | 83 | } |
| 72 | 84 | |
| 73 | | TILE_GET_INFO_MEMBER(supduck_state::get_tx_tile_info) |
| 85 | TILE_GET_INFO_MEMBER(supduck_state::get_tx_tile_info) // same as tigeroad.c |
| 74 | 86 | { |
| 75 | | int data = m_tx_videoram[tile_index]; |
| 76 | | |
| 77 | | int tileno = data & 0xff; |
| 78 | | // tileno |= (data & 0x7000) >> 4; |
| 87 | UINT16 *videoram = m_tx_videoram; |
| 88 | int data = videoram[tile_index]; |
| 89 | int attr = data >> 8; |
| 90 | int code = (data & 0xff) + ((attr & 0xc0) << 2) + ((attr & 0x20) << 5); |
| 91 | int color = attr & 0x0f; |
| 92 | int flags = (attr & 0x10) ? TILE_FLIPY : 0; |
| 79 | 93 | |
| 80 | | SET_TILE_INFO_MEMBER(0, tileno, 0, 0); |
| 94 | SET_TILE_INFO_MEMBER(0, code, color, flags); |
| 81 | 95 | } |
| 82 | 96 | |
| 83 | 97 | |
| 98 | void supduck_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority ) |
| 99 | { |
| 100 | UINT16 *source = &m_spriteram->buffer()[m_spriteram->bytes()/2] - 4; |
| 101 | UINT16 *finish = m_spriteram->buffer(); |
| 84 | 102 | |
| 103 | while (source >= finish) |
| 104 | { |
| 105 | int tile_number = source[0]; |
| 85 | 106 | |
| 107 | if (tile_number != 0xfff) { |
| 108 | int attr = source[1]; |
| 109 | int sy = source[2] & 0x1ff; |
| 110 | int sx = source[3] & 0x1ff; |
| 111 | |
| 112 | int flipx = attr & 0x02; |
| 113 | int flipy = attr & 0x01; |
| 114 | int color = (attr >> 2) & 0x0f; |
| 115 | |
| 116 | if (sx > 0x100) sx -= 0x200; |
| 117 | if (sy > 0x100) sy -= 0x200; |
| 118 | |
| 119 | if (flip_screen()) |
| 120 | { |
| 121 | sx = 240 - sx; |
| 122 | sy = 240 - sy; |
| 123 | flipx = !flipx; |
| 124 | flipy = !flipy; |
| 125 | } |
| 126 | |
| 127 | |
| 128 | m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 129 | tile_number, |
| 130 | color, |
| 131 | flipx, flipy, |
| 132 | sx, 240 - sy, 15); |
| 133 | } |
| 134 | |
| 135 | source -= 4; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | |
| 140 | |
| 86 | 141 | static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, supduck_state ) |
| 87 | 142 | AM_RANGE(0x000000, 0x03ffff) AM_ROM |
| 88 | | AM_RANGE(0xfe0000, 0xfe1fff) AM_RAM |
| 143 | AM_RANGE(0xfe0000, 0xfe1fff) AM_RAM AM_SHARE("spriteram") |
| 89 | 144 | // AM_RANGE(0xfe0000, 0xfe07ff) AM_RAM /* RAM? */ |
| 90 | 145 | // AM_RANGE(0xfe0800, 0xfe0cff) AM_RAM AM_SHARE("spriteram") |
| 91 | 146 | // AM_RANGE(0xfe0d00, 0xfe3fff) AM_RAM /* RAM? */ |
| r242044 | r242045 | |
| 265 | 320 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 266 | 321 | MCFG_SCREEN_UPDATE_DRIVER(supduck_state, screen_update) |
| 267 | 322 | MCFG_SCREEN_SIZE(32*8, 32*8) |
| 268 | | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1) |
| 323 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 30*8-1) |
| 269 | 324 | MCFG_SCREEN_PALETTE("palette") |
| 325 | MCFG_SCREEN_VBLANK_DEVICE("spriteram", buffered_spriteram16_device, vblank_copy_rising) |
| 270 | 326 | |
| 327 | MCFG_BUFFERED_SPRITERAM16_ADD("spriteram") |
| 328 | |
| 271 | 329 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", supduck) |
| 272 | 330 | |
| 273 | 331 | MCFG_PALETTE_ADD("palette", 0x800/2) |
| r242044 | r242045 | |
| 324 | 382 | ROM_LOAD( "1.su13", 0x00000, 0x80000, CRC(7fb1ed42) SHA1(77ec86a6454398e329066aa060e9b6a39085ce71) ) // banked sample data |
| 325 | 383 | ROM_END |
| 326 | 384 | |
| 327 | | GAME( 1993, supduck, 0, supduck, supduck, driver_device, 0, ROT0, "Comad", "Super Duck", GAME_NOT_WORKING ) |
| 385 | GAME( 1992, supduck, 0, supduck, supduck, driver_device, 0, ROT0, "Comad", "Super Duck", GAME_NOT_WORKING ) |