Previous 199869 Revisions Next

r33533 Tuesday 25th November, 2014 at 20:46:07 UTC by David Haywood
add sprite code from pushman, it's very similar except it has real tilemaps instead of a fixed layout from rom (nw)
(will probably deviceify / merge at some point)
[src/mame/drivers]supduck.c

trunk/src/mame/drivers/supduck.c
r242044r242045
1313#include "cpu/z80/z80.h"
1414#include "cpu/m68000/m68000.h"
1515#include "sound/okim6295.h"
16#include "video/bufsprite.h"
1617
17
1818class supduck_state : public driver_device
1919{
2020public:
r242044r242045
2222      : driver_device(mconfig, type, tag),
2323         m_maincpu(*this, "maincpu"),
2424         m_audiocpu(*this, "audiocpu"),
25         m_spriteram(*this, "spriteram") ,
2526         m_tx_videoram(*this, "txvideoram"),
26         m_gfxdecode(*this, "gfxdecode")
27         m_gfxdecode(*this, "gfxdecode"),
28         m_palette(*this, "palette")
2729   { }
2830
2931   // devices
r242044r242045
3133   required_device<z80_device> m_audiocpu;
3234
3335   // shared pointers
36   required_device<buffered_spriteram16_device> m_spriteram;
3437   required_shared_ptr<UINT16> m_tx_videoram;
3538
3639   required_device<gfxdecode_device> m_gfxdecode;
40   required_device<palette_device> m_palette;
3741
3842   tilemap_t     *m_tx_tilemap;
3943
r242044r242045
4953
5054   virtual void video_start();
5155
56   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
5257   TILE_GET_INFO_MEMBER(get_tx_tile_info);
5358};
5459
5560void supduck_state::video_start()
5661{
5762   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
5865}
5966
6067UINT32 supduck_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
6168{
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
6274   m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0);
6375   return 0;
6476}
r242044r242045
7082   m_tx_tilemap->mark_tile_dirty(offset);
7183}
7284
73TILE_GET_INFO_MEMBER(supduck_state::get_tx_tile_info)
85TILE_GET_INFO_MEMBER(supduck_state::get_tx_tile_info) // same as tigeroad.c
7486{
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;
7993
80   SET_TILE_INFO_MEMBER(0, tileno, 0, 0);
94   SET_TILE_INFO_MEMBER(0, code, color, flags);
8195}
8296
8397
98void 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();
84102
103   while (source >= finish)
104   {
105      int tile_number = source[0];
85106
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
86141static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, supduck_state )
87142   AM_RANGE(0x000000, 0x03ffff) AM_ROM
88   AM_RANGE(0xfe0000, 0xfe1fff) AM_RAM
143   AM_RANGE(0xfe0000, 0xfe1fff) AM_RAM AM_SHARE("spriteram")
89144//   AM_RANGE(0xfe0000, 0xfe07ff) AM_RAM /* RAM? */
90145//   AM_RANGE(0xfe0800, 0xfe0cff) AM_RAM AM_SHARE("spriteram")
91146//   AM_RANGE(0xfe0d00, 0xfe3fff) AM_RAM              /* RAM? */
r242044r242045
265320   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
266321   MCFG_SCREEN_UPDATE_DRIVER(supduck_state, screen_update)
267322   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)
269324   MCFG_SCREEN_PALETTE("palette")
325   MCFG_SCREEN_VBLANK_DEVICE("spriteram", buffered_spriteram16_device, vblank_copy_rising)
270326
327   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
328
271329   MCFG_GFXDECODE_ADD("gfxdecode", "palette", supduck)
272330
273331   MCFG_PALETTE_ADD("palette", 0x800/2)
r242044r242045
324382   ROM_LOAD( "1.su13",   0x00000, 0x80000, CRC(7fb1ed42) SHA1(77ec86a6454398e329066aa060e9b6a39085ce71) ) // banked sample data
325383ROM_END
326384
327GAME( 1993, supduck, 0, supduck, supduck, driver_device, 0, ROT0, "Comad", "Super Duck", GAME_NOT_WORKING )
385GAME( 1992, supduck, 0, supduck, supduck, driver_device, 0, ROT0, "Comad", "Super Duck", GAME_NOT_WORKING )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team