trunk/src/mame/drivers/thedeep.c
| r245097 | r245098 | |
| 436 | 436 | MCFG_PALETTE_ADD("palette", 512) |
| 437 | 437 | MCFG_PALETTE_INIT_OWNER(thedeep_state, thedeep) |
| 438 | 438 | |
| 439 | MCFG_DEVICE_ADD("spritegen", DECO_MXC06, 0) |
| 440 | deco_mxc06_device::set_gfx_region(*device, 0); |
| 441 | MCFG_DECO_MXC06_GFXDECODE("gfxdecode") |
| 442 | MCFG_DECO_MXC06_PALETTE("palette") |
| 443 | MCFG_DECO_MXC06_RAMSIZE(0x400) |
| 439 | 444 | |
| 440 | 445 | /* sound hardware */ |
| 441 | 446 | MCFG_SPEAKER_STANDARD_MONO("mono") |
trunk/src/mame/includes/thedeep.h
| r245097 | r245098 | |
| 1 | #include "video/decmxc06.h" |
| 2 | |
| 3 | |
| 1 | 4 | class thedeep_state : public driver_device |
| 2 | 5 | { |
| 3 | 6 | public: |
| r245097 | r245098 | |
| 12 | 15 | m_vram_0(*this, "vram_0"), |
| 13 | 16 | m_vram_1(*this, "vram_1"), |
| 14 | 17 | m_scroll(*this, "scroll"), |
| 15 | | m_scroll2(*this, "scroll2") { } |
| 18 | m_scroll2(*this, "scroll2"), |
| 19 | m_spritegen(*this, "spritegen") |
| 20 | { } |
| 16 | 21 | |
| 17 | 22 | required_device<cpu_device> m_maincpu; |
| 18 | 23 | required_device<cpu_device> m_audiocpu; |
| r245097 | r245098 | |
| 25 | 30 | required_shared_ptr<UINT8> m_vram_1; |
| 26 | 31 | required_shared_ptr<UINT8> m_scroll; |
| 27 | 32 | required_shared_ptr<UINT8> m_scroll2; |
| 33 | required_device<deco_mxc06_device> m_spritegen; |
| 28 | 34 | |
| 29 | 35 | int m_nmi_enable; |
| 30 | 36 | UINT8 m_protection_command; |
| r245097 | r245098 | |
| 59 | 65 | DECLARE_PALETTE_INIT(thedeep); |
| 60 | 66 | |
| 61 | 67 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 62 | | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 63 | 68 | |
| 64 | 69 | INTERRUPT_GEN_MEMBER(mcu_irq); |
| 65 | 70 | TIMER_DEVICE_CALLBACK_MEMBER(interrupt); |
trunk/src/mame/video/decmxc06.c
| r245097 | r245098 | |
| 51 | 51 | : device_t(mconfig, DECO_MXC06, "DECO MXC06 Sprite", tag, owner, clock, "deco_mxc06", __FILE__), |
| 52 | 52 | device_video_interface(mconfig, *this), |
| 53 | 53 | m_gfxregion(0), |
| 54 | m_ramsize(0x800), |
| 54 | 55 | m_gfxdecode(*this), |
| 55 | 56 | m_palette(*this) |
| 56 | 57 | { |
| r245097 | r245098 | |
| 73 | 74 | int offs; |
| 74 | 75 | |
| 75 | 76 | offs = 0; |
| 76 | | while (offs < 0x800 / 2) |
| 77 | while (offs < m_ramsize / 2) |
| 77 | 78 | { |
| 78 | 79 | int sx, sy, code, color, w, h, flipx, flipy, incy, flash, mult, x, y; |
| 79 | 80 | |
| r245097 | r245098 | |
| 109 | 110 | else |
| 110 | 111 | mult = -16; |
| 111 | 112 | |
| 113 | |
| 114 | // thedeep strongly suggests that this check goes here, otherwise the radar breaks |
| 115 | if (!(spriteram[offs] & 0x8000)) |
| 116 | { |
| 117 | offs += 4; |
| 118 | continue; |
| 119 | } |
| 120 | |
| 121 | |
| 112 | 122 | for (x = 0; x < w; x++) |
| 113 | 123 | { |
| 114 | 124 | // maybe, birdie try appears to specify the base code for each part.. |
| 115 | 125 | code = spriteram[offs + 1] & 0x1fff; |
| 116 | 126 | |
| 117 | | code &= ~(h-1); |
| 127 | code &= ~(h - 1); |
| 118 | 128 | |
| 119 | 129 | if (flipy) |
| 120 | 130 | incy = -1; |
| 121 | 131 | else |
| 122 | 132 | { |
| 123 | | code += h-1; |
| 133 | code += h - 1; |
| 124 | 134 | incy = 1; |
| 125 | 135 | } |
| 126 | 136 | |
| 127 | 137 | for (y = 0; y < h; y++) |
| 128 | 138 | { |
| 129 | | if (spriteram[offs] & 0x8000) |
| 130 | 139 | { |
| 131 | 140 | int draw = 0; |
| 132 | 141 | if (!flash || (m_screen->frame_number() & 1)) |
| 133 | 142 | { |
| 134 | | if (m_priority_type==0) // most cases |
| 143 | if (m_priority_type == 0) // most cases |
| 135 | 144 | { |
| 136 | 145 | if ((color & pri_mask) == pri_val) |
| 137 | 146 | { |
| 138 | 147 | draw = 1; |
| 139 | 148 | } |
| 140 | 149 | } |
| 141 | | else if (m_priority_type==1) // vaportra |
| 150 | else if (m_priority_type == 1) // vaportra |
| 142 | 151 | { |
| 143 | 152 | if (pri_mask && (color >= pri_val)) |
| 144 | 153 | continue; |
| r245097 | r245098 | |
| 152 | 161 | |
| 153 | 162 | if (draw) |
| 154 | 163 | { |
| 155 | | m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap,cliprect, |
| 164 | m_gfxdecode->gfx(m_gfxregion)->transpen(bitmap, cliprect, |
| 156 | 165 | code - y * incy, |
| 157 | 166 | color & col_mask, |
| 158 | | flipx,flipy, |
| 159 | | sx + (mult * x),sy + (mult * y),0); |
| 167 | flipx, flipy, |
| 168 | sx + (mult * x), sy + (mult * y), 0); |
| 160 | 169 | } |
| 161 | 170 | } |
| 162 | 171 | } |
| 163 | 172 | |
| 164 | 173 | offs += 4; |
| 165 | | if (offs >= 0x800 / 2) |
| 166 | | return; |
| 174 | if (offs >= m_ramsize / 2) |
| 175 | return; |
| 176 | |
| 177 | |
| 167 | 178 | } |
| 168 | 179 | } |
| 169 | 180 | } |
| r245097 | r245098 | |
| 175 | 186 | int offs; |
| 176 | 187 | |
| 177 | 188 | offs = 0; |
| 178 | | while (offs < 0x800 / 2) |
| 189 | while (offs < m_ramsize / 2) |
| 179 | 190 | { |
| 180 | 191 | int sx, sy, code, color, flipx, flipy; |
| 181 | 192 | |
trunk/src/mame/video/decmxc06.h
| r245097 | r245098 | |
| 11 | 11 | static void static_set_gfxdecode_tag(device_t &device, const char *tag); |
| 12 | 12 | static void static_set_palette_tag(device_t &device, const char *tag); |
| 13 | 13 | static void set_gfx_region(device_t &device, int region); |
| 14 | static void set_ram_size(device_t &device, int size) |
| 15 | { |
| 16 | deco_mxc06_device &dev = downcast<deco_mxc06_device &>(device); |
| 17 | dev.m_ramsize = size; |
| 18 | } |
| 14 | 19 | |
| 20 | |
| 15 | 21 | void set_gfxregion(int region) { m_gfxregion = region; }; |
| 16 | 22 | void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram16, int pri_mask, int pri_val, int col_mask ); |
| 17 | 23 | void draw_sprites_bootleg( bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram, int pri_mask, int pri_val, int col_mask ); |
| r245097 | r245098 | |
| 23 | 29 | |
| 24 | 30 | UINT8 m_gfxregion; |
| 25 | 31 | int m_priority_type; // just so we can support the existing drivers without converting everything to pdrawgfx just yet |
| 32 | int m_ramsize; |
| 26 | 33 | |
| 27 | 34 | private: |
| 28 | 35 | required_device<gfxdecode_device> m_gfxdecode; |
| r245097 | r245098 | |
| 36 | 43 | |
| 37 | 44 | #define MCFG_DECO_MXC06_PALETTE(_palette_tag) \ |
| 38 | 45 | deco_mxc06_device::static_set_palette_tag(*device, "^" _palette_tag); |
| 46 | |
| 47 | #define MCFG_DECO_MXC06_RAMSIZE(_size) \ |
| 48 | deco_mxc06_device::set_ram_size(*device, _size); |
trunk/src/mame/video/thedeep.c
| r245097 | r245098 | |
| 109 | 109 | |
| 110 | 110 | /*************************************************************************** |
| 111 | 111 | |
| 112 | | Sprites Drawing |
| 113 | | |
| 114 | | Offset: Bits: Value: |
| 115 | | |
| 116 | | 0 Y (low bits, 0 is bottom) |
| 117 | | |
| 118 | | 1 7------- Enable |
| 119 | | -6------ Flip Y |
| 120 | | --5----- Flip X ? (unused) |
| 121 | | ---43--- Height: 1,2,4 or 8 tiles |
| 122 | | -----21- Width: 1,2,4 or 8 tiles* |
| 123 | | -------0 Y (High bit) |
| 124 | | |
| 125 | | 2 Code (low bits) |
| 126 | | |
| 127 | | 3 Code (high bits) |
| 128 | | |
| 129 | | 4 X (low bits, 0 is right) |
| 130 | | |
| 131 | | 5 7654---- Color |
| 132 | | ----321- |
| 133 | | -------0 X (High bit) |
| 134 | | |
| 135 | | 6 Unused |
| 136 | | |
| 137 | | 7 Unused |
| 138 | | |
| 139 | | * a sprite of width N uses N consecutive sprites. The first one specifies |
| 140 | | all the data, the following ones only the tile code and color. |
| 141 | | |
| 142 | | ***************************************************************************/ |
| 143 | | |
| 144 | | void thedeep_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 145 | | { |
| 146 | | UINT8 *s = m_spriteram, *end = s + m_spriteram.bytes(); |
| 147 | | |
| 148 | | while (s < end) |
| 149 | | { |
| 150 | | int code,color,sx,sy,flipx,flipy,nx,ny,x,y,attr; |
| 151 | | |
| 152 | | attr = s[1]; |
| 153 | | if (!(attr & 0x80)) { s+=8; continue; } |
| 154 | | |
| 155 | | sx = s[4]; |
| 156 | | sy = s[0]; |
| 157 | | |
| 158 | | color = s[5]; |
| 159 | | |
| 160 | | flipx = attr & 0x00; // ? |
| 161 | | flipy = attr & 0x40; |
| 162 | | |
| 163 | | nx = 1 << ((attr & 0x06) >> 1); |
| 164 | | ny = 1 << ((attr & 0x18) >> 3); |
| 165 | | |
| 166 | | if (color & 1) sx -= 256; |
| 167 | | if (attr & 1) sy -= 256; |
| 168 | | |
| 169 | | if (flip_screen()) |
| 170 | | { |
| 171 | | flipx = !flipx; |
| 172 | | flipy = !flipy; |
| 173 | | sy = sy - 8; |
| 174 | | } |
| 175 | | else |
| 176 | | { |
| 177 | | sx = 240 - sx; |
| 178 | | sy = 240 - sy - ny * 16 + 16; |
| 179 | | } |
| 180 | | |
| 181 | | for (x = 0; (x < nx) && (s < end); x++,s+=8) |
| 182 | | { |
| 183 | | code = s[2] + (s[3] << 8); |
| 184 | | color = s[5] >> 4; |
| 185 | | |
| 186 | | for (y = 0; y < ny; y++) |
| 187 | | { |
| 188 | | m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, |
| 189 | | code + (flipy ? (ny - y - 1) : y), |
| 190 | | color, |
| 191 | | flipx,flipy, |
| 192 | | sx + x * (flipx ? 16 : -16), sy + y * 16,0 ); |
| 193 | | } |
| 194 | | } |
| 195 | | } |
| 196 | | } |
| 197 | | |
| 198 | | |
| 199 | | /*************************************************************************** |
| 200 | | |
| 201 | 112 | Screen Drawing |
| 202 | 113 | |
| 203 | 114 | ***************************************************************************/ |
| r245097 | r245098 | |
| 219 | 130 | bitmap.fill(m_palette->black_pen(), cliprect); |
| 220 | 131 | |
| 221 | 132 | m_tilemap_0->draw(screen, bitmap, cliprect, 0,0); |
| 222 | | draw_sprites(bitmap,cliprect); |
| 133 | m_spritegen->draw_sprites(bitmap, cliprect, reinterpret_cast<UINT16 *>(m_spriteram.target()), 0x00, 0x00, 0x0f); |
| 223 | 134 | m_tilemap_1->draw(screen, bitmap, cliprect, 0,0); |
| 224 | 135 | return 0; |
| 225 | 136 | } |
| 137 | |