trunk/src/mame/video/tbowl.c
| r20720 | r20721 | |
| 104 | 104 | m_bg2yscroll = (m_bg2yscroll & 0x00ff) | (data << 8); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll) |
| 107 | |
| 108 | /*** Video Start / Update ***/ |
| 109 | |
| 110 | void tbowl_state::video_start() |
| 108 | 111 | { |
| 109 | | tbowl_state *state = machine.driver_data<tbowl_state>(); |
| 112 | m_tx_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_tx_tile_info),this),TILEMAP_SCAN_ROWS, 8, 8,64,32); |
| 113 | m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32); |
| 114 | m_bg2_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg2_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32); |
| 115 | |
| 116 | m_tx_tilemap->set_transparent_pen(0); |
| 117 | m_bg_tilemap->set_transparent_pen(0); |
| 118 | m_bg2_tilemap->set_transparent_pen(0); |
| 119 | } |
| 120 | |
| 121 | |
| 122 | void tbowl_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll, UINT8* spriteram) |
| 123 | { |
| 110 | 124 | int offs; |
| 111 | 125 | static const UINT8 layout[8][8] = |
| 112 | 126 | { |
| r20720 | r20721 | |
| 122 | 136 | |
| 123 | 137 | for (offs = 0;offs < 0x800;offs += 8) |
| 124 | 138 | { |
| 125 | | if (state->m_spriteram[offs+0] & 0x80) /* enable */ |
| 139 | if (spriteram[offs+0] & 0x80) /* enable */ |
| 126 | 140 | { |
| 127 | 141 | int code,color,sizex,sizey,flipx,flipy,xpos,ypos; |
| 128 | 142 | int x,y;//,priority,priority_mask; |
| 129 | 143 | |
| 130 | | code = (state->m_spriteram[offs+2])+(state->m_spriteram[offs+1]<<8); |
| 131 | | color = (state->m_spriteram[offs+3])&0x1f; |
| 132 | | sizex = 1 << ((state->m_spriteram[offs+0] & 0x03) >> 0); |
| 133 | | sizey = 1 << ((state->m_spriteram[offs+0] & 0x0c) >> 2); |
| 144 | code = (spriteram[offs+2])+(spriteram[offs+1]<<8); |
| 145 | color = (spriteram[offs+3])&0x1f; |
| 146 | sizex = 1 << ((spriteram[offs+0] & 0x03) >> 0); |
| 147 | sizey = 1 << ((spriteram[offs+0] & 0x0c) >> 2); |
| 134 | 148 | |
| 135 | | flipx = (state->m_spriteram[offs+0])&0x20; |
| 149 | flipx = (spriteram[offs+0])&0x20; |
| 136 | 150 | flipy = 0; |
| 137 | | xpos = (state->m_spriteram[offs+6])+((state->m_spriteram[offs+4]&0x03)<<8); |
| 138 | | ypos = (state->m_spriteram[offs+5])+((state->m_spriteram[offs+4]&0x10)<<4); |
| 151 | xpos = (spriteram[offs+6])+((spriteram[offs+4]&0x03)<<8); |
| 152 | ypos = (spriteram[offs+5])+((spriteram[offs+4]&0x10)<<4); |
| 139 | 153 | |
| 140 | 154 | /* bg: 1; fg:2; text: 4 */ |
| 141 | 155 | |
| r20720 | r20721 | |
| 181 | 195 | } |
| 182 | 196 | } |
| 183 | 197 | } |
| 184 | | |
| 185 | 198 | } |
| 186 | 199 | |
| 187 | | |
| 188 | | /*** Video Start / Update ***/ |
| 189 | | |
| 190 | | void tbowl_state::video_start() |
| 191 | | { |
| 192 | | m_tx_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_tx_tile_info),this),TILEMAP_SCAN_ROWS, 8, 8,64,32); |
| 193 | | m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32); |
| 194 | | m_bg2_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(tbowl_state::get_bg2_tile_info),this),TILEMAP_SCAN_ROWS, 16, 16,128,32); |
| 195 | | |
| 196 | | m_tx_tilemap->set_transparent_pen(0); |
| 197 | | m_bg_tilemap->set_transparent_pen(0); |
| 198 | | m_bg2_tilemap->set_transparent_pen(0); |
| 199 | | } |
| 200 | | |
| 201 | | |
| 202 | 200 | UINT32 tbowl_state::screen_update_tbowl_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 203 | 201 | { |
| 204 | 202 | m_bg_tilemap->set_scrollx(0, m_xscroll ); |
| r20720 | r20721 | |
| 210 | 208 | |
| 211 | 209 | bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */ |
| 212 | 210 | m_bg_tilemap->draw(bitmap, cliprect, 0,0); |
| 213 | | draw_sprites(machine(), bitmap,cliprect, 0); |
| 211 | tbowl_draw_sprites(machine(), bitmap,cliprect, 0, m_spriteram); |
| 214 | 212 | m_bg2_tilemap->draw(bitmap, cliprect, 0,0); |
| 215 | 213 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 216 | 214 | |
| r20720 | r20721 | |
| 228 | 226 | |
| 229 | 227 | bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */ |
| 230 | 228 | m_bg_tilemap->draw(bitmap, cliprect, 0,0); |
| 231 | | draw_sprites(machine(), bitmap,cliprect, 32*8); |
| 229 | tbowl_draw_sprites(machine(), bitmap,cliprect, 32*8, m_spriteram); |
| 232 | 230 | m_bg2_tilemap->draw(bitmap, cliprect, 0,0); |
| 233 | 231 | m_tx_tilemap->draw(bitmap, cliprect, 0,0); |
| 234 | 232 | |
trunk/src/mame/video/spbactn.c
| r20720 | r20721 | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
| 35 | | /* from gals pinball (which was in turn from ninja gaiden) */ |
| 36 | | static int draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites) |
| 37 | | { |
| 38 | | static const UINT8 layout[8][8] = |
| 39 | | { |
| 40 | | { 0, 1, 4, 5,16,17,20,21}, |
| 41 | | { 2, 3, 6, 7,18,19,22,23}, |
| 42 | | { 8, 9,12,13,24,25,28,29}, |
| 43 | | {10,11,14,15,26,27,30,31}, |
| 44 | | {32,33,36,37,48,49,52,53}, |
| 45 | | {34,35,38,39,50,51,54,55}, |
| 46 | | {40,41,44,45,56,57,60,61}, |
| 47 | | {42,43,46,47,58,59,62,63} |
| 48 | | }; |
| 49 | 35 | |
| 50 | | spbactn_state *state = machine.driver_data<spbactn_state>(); |
| 51 | | int count = 0; |
| 52 | | int offs; |
| 53 | | |
| 54 | | for (offs = (0x1000 - 16) / 2; offs >= 0; offs -= 8) |
| 55 | | { |
| 56 | | int sx, sy, code, color, size, attr, flipx, flipy; |
| 57 | | int col, row; |
| 58 | | |
| 59 | | attr = state->m_spvideoram[offs]; |
| 60 | | |
| 61 | | int pri = (state->m_spvideoram[offs] & 0x0030); |
| 62 | | // int pri = (state->m_spvideoram[offs+2] & 0x0030); |
| 63 | | |
| 64 | | |
| 65 | | if ((attr & 0x0004) && |
| 66 | | ((pri & 0x0030) >> 4) == priority) |
| 67 | | { |
| 68 | | flipx = attr & 0x0001; |
| 69 | | flipy = attr & 0x0002; |
| 70 | | |
| 71 | | code = state->m_spvideoram[offs + 1]; |
| 72 | | |
| 73 | | if (alt_sprites) |
| 74 | | { |
| 75 | | color = state->m_spvideoram[offs + 0]; |
| 76 | | } |
| 77 | | else |
| 78 | | { |
| 79 | | color = state->m_spvideoram[offs + 2]; |
| 80 | | } |
| 81 | | |
| 82 | | size = 1 << (state->m_spvideoram[offs + 2] & 0x0003); /* 1,2,4,8 */ |
| 83 | | color = (color & 0x00f0) >> 4; |
| 84 | | |
| 85 | | sx = state->m_spvideoram[offs + 4]; |
| 86 | | sy = state->m_spvideoram[offs + 3]; |
| 87 | | |
| 88 | | attr &= ~0x0040; /* !!! */ |
| 89 | | |
| 90 | | if (attr & 0x0040) |
| 91 | | color |= 0x0180; |
| 92 | | else |
| 93 | | color |= 0x0080; |
| 94 | | |
| 95 | | |
| 96 | | for (row = 0; row < size; row++) |
| 97 | | { |
| 98 | | for (col = 0; col < size; col++) |
| 99 | | { |
| 100 | | int x = sx + 8 * (flipx ? (size - 1 - col) : col); |
| 101 | | int y = sy + 8 * (flipy ? (size - 1 - row) : row); |
| 102 | | |
| 103 | | drawgfx_transpen_raw(bitmap, cliprect, machine.gfx[2], |
| 104 | | code + layout[row][col], |
| 105 | | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 106 | | flipx, flipy, |
| 107 | | x, y, |
| 108 | | 0); |
| 109 | | } |
| 110 | | } |
| 111 | | |
| 112 | | count++; |
| 113 | | } |
| 114 | | } |
| 115 | | |
| 116 | | return count; |
| 117 | | } |
| 118 | | |
| 119 | | |
| 120 | 36 | WRITE16_MEMBER(spbactn_state::bg_videoram_w) |
| 121 | 37 | { |
| 122 | 38 | COMBINE_DATA(&m_bgvideoram[offset]); |
| r20720 | r20721 | |
| 238 | 154 | |
| 239 | 155 | |
| 240 | 156 | |
| 241 | | if (draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 0, alt_sprites)) |
| 157 | if (spbactn_draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 0, alt_sprites, m_spvideoram)) |
| 242 | 158 | { |
| 243 | 159 | m_bg_tilemap->draw(m_tile_bitmap_bg, cliprect, 0, 0); |
| 244 | 160 | } |
| 245 | 161 | |
| 246 | | draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 1, alt_sprites); |
| 162 | spbactn_draw_sprites(machine(), m_tile_bitmap_bg, cliprect, 1, alt_sprites, m_spvideoram); |
| 247 | 163 | |
| 248 | 164 | m_fg_tilemap->draw(m_tile_bitmap_fg, cliprect, 0, 0); |
| 249 | 165 | |
| 250 | 166 | |
| 251 | | draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 2, alt_sprites); |
| 252 | | draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 3, alt_sprites); |
| 167 | spbactn_draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 2, alt_sprites, m_spvideoram); |
| 168 | spbactn_draw_sprites(machine(), m_tile_bitmap_fg, cliprect, 3, alt_sprites, m_spvideoram); |
| 253 | 169 | |
| 254 | 170 | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 255 | 171 | blendbitmaps(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, cliprect); |
trunk/src/mame/video/tecmo_spr.c
| r0 | r20721 | |
| 1 | /* Various Tecmo Sprite implementations |
| 2 | - for unifying and converting to a device |
| 3 | |
| 4 | - check wc90.c, tecmo.c, tbowl.c others? - they seem more significantly different but are they close to each other |
| 5 | (but at the same time use the same 'layout' table as this implementation) |
| 6 | |
| 7 | - is there a single chip responsible for these, or is it just a family of closely connected implementations? |
| 8 | (because we seem to need some per-game code right now) |
| 9 | |
| 10 | */ |
| 11 | |
| 12 | |
| 13 | #include "emu.h" |
| 14 | #include "tecmo_spr.h" |
| 15 | |
| 16 | |
| 17 | |
| 18 | static const UINT8 layout[8][8] = |
| 19 | { |
| 20 | { 0, 1, 4, 5,16,17,20,21}, |
| 21 | { 2, 3, 6, 7,18,19,22,23}, |
| 22 | { 8, 9,12,13,24,25,28,29}, |
| 23 | {10,11,14,15,26,27,30,31}, |
| 24 | {32,33,36,37,48,49,52,53}, |
| 25 | {34,35,38,39,50,51,54,55}, |
| 26 | {40,41,44,45,56,57,60,61}, |
| 27 | {42,43,46,47,58,59,62,63} |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | /* sprite format (gaiden): |
| 34 | * |
| 35 | * word bit usage |
| 36 | * --------+-fedcba9876543210-+---------------- |
| 37 | * 0 | ---------------x | flip x |
| 38 | * | --------------x- | flip y |
| 39 | * | -------------x-- | enable |
| 40 | * | ----------x----- | blend |
| 41 | * | --------xx------ | sprite-tile priority |
| 42 | * 1 | xxxxxxxxxxxxxxxx | number |
| 43 | * 2 | --------xxxx---- | palette |
| 44 | * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 |
| 45 | * 3 | xxxxxxxxxxxxxxxx | y position |
| 46 | * 4 | xxxxxxxxxxxxxxxx | x position |
| 47 | * 5,6,7| | unused |
| 48 | */ |
| 49 | |
| 50 | /* sprite format (galspnbl): |
| 51 | * |
| 52 | * word bit usage |
| 53 | * --------+-fedcba9876543210-+---------------- |
| 54 | * 0 | ---------------x | flip x |
| 55 | * | --------------x- | flip y |
| 56 | * | -------------x-- | enable |
| 57 | * | ----------xx---- | priority? |
| 58 | * | ---------x------ | flicker? |
| 59 | * 1 | xxxxxxxxxxxxxxxx | code |
| 60 | * 2 | --------xxxx---- | color |
| 61 | * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 |
| 62 | * 3 | xxxxxxxxxxxxxxxx | y position |
| 63 | * 4 | xxxxxxxxxxxxxxxx | x position |
| 64 | * 5,6,7| | unused |
| 65 | */ |
| 66 | |
| 67 | |
| 68 | /* from gals pinball (which was in turn from ninja gaiden) */ |
| 69 | int spbactn_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram) |
| 70 | { |
| 71 | int count = 0; |
| 72 | int offs; |
| 73 | |
| 74 | for (offs = (0x1000 - 16) / 2; offs >= 0; offs -= 8) |
| 75 | { |
| 76 | int sx, sy, code, color, size, attr, flipx, flipy; |
| 77 | int col, row; |
| 78 | |
| 79 | attr = spriteram[offs]; |
| 80 | |
| 81 | int pri = (spriteram[offs] & 0x0030); |
| 82 | // int pri = (spriteram[offs+2] & 0x0030); |
| 83 | |
| 84 | |
| 85 | if ((attr & 0x0004) && |
| 86 | ((pri & 0x0030) >> 4) == priority) |
| 87 | { |
| 88 | flipx = attr & 0x0001; |
| 89 | flipy = attr & 0x0002; |
| 90 | |
| 91 | code = spriteram[offs + 1]; |
| 92 | |
| 93 | if (alt_sprites) |
| 94 | { |
| 95 | color = spriteram[offs + 0]; |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | color = spriteram[offs + 2]; |
| 100 | } |
| 101 | |
| 102 | size = 1 << (spriteram[offs + 2] & 0x0003); /* 1,2,4,8 */ |
| 103 | color = (color & 0x00f0) >> 4; |
| 104 | |
| 105 | sx = spriteram[offs + 4]; |
| 106 | sy = spriteram[offs + 3]; |
| 107 | |
| 108 | attr &= ~0x0040; /* !!! */ |
| 109 | |
| 110 | if (attr & 0x0040) |
| 111 | color |= 0x0180; |
| 112 | else |
| 113 | color |= 0x0080; |
| 114 | |
| 115 | |
| 116 | for (row = 0; row < size; row++) |
| 117 | { |
| 118 | for (col = 0; col < size; col++) |
| 119 | { |
| 120 | int x = sx + 8 * (flipx ? (size - 1 - col) : col); |
| 121 | int y = sy + 8 * (flipy ? (size - 1 - row) : row); |
| 122 | |
| 123 | drawgfx_transpen_raw(bitmap, cliprect, machine.gfx[2], |
| 124 | code + layout[row][col], |
| 125 | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 126 | flipx, flipy, |
| 127 | x, y, |
| 128 | 0); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | count++; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return count; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | // comad bootleg of spbactn |
| 141 | void galspnbl_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes ) |
| 142 | { |
| 143 | int offs; |
| 144 | |
| 145 | |
| 146 | for (offs = (spriteram_bytes - 16) / 2; offs >= 0; offs -= 8) |
| 147 | { |
| 148 | int sx, sy, code, color, size, attr, flipx, flipy; |
| 149 | int col, row; |
| 150 | |
| 151 | attr = spriteram[offs]; |
| 152 | if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (machine.primary_screen->frame_number() & 1)) |
| 153 | // && ((attr & 0x0030) >> 4) == priority) |
| 154 | && ((attr & 0x0020) >> 5) == priority) |
| 155 | { |
| 156 | code = spriteram[offs + 1]; |
| 157 | color = spriteram[offs + 2]; |
| 158 | size = 1 << (color & 0x0003); // 1,2,4,8 |
| 159 | color = (color & 0x00f0) >> 4; |
| 160 | // sx = spriteram[offs + 4] + screenscroll; |
| 161 | sx = spriteram[offs + 4]; |
| 162 | sy = spriteram[offs + 3]; |
| 163 | flipx = attr & 0x0001; |
| 164 | flipy = attr & 0x0002; |
| 165 | |
| 166 | for (row = 0; row < size; row++) |
| 167 | { |
| 168 | for (col = 0; col < size; col++) |
| 169 | { |
| 170 | int x = sx + 8 * (flipx ? (size - 1 - col) : col); |
| 171 | int y = sy + 8 * (flipy ? (size - 1 - row) : row); |
| 172 | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 173 | code + layout[row][col], |
| 174 | color, |
| 175 | flipx,flipy, |
| 176 | x,y,0); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | void tecmo16_draw_sprites(running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, UINT16 spriteram16_bytes, int game_is_riot, int flipscreen ) |
| 184 | { |
| 185 | UINT16 *spriteram16 = spriteram; |
| 186 | int offs; |
| 187 | |
| 188 | bitmap_ind16 &bitmap = bitmap_bg; |
| 189 | |
| 190 | for (offs = spriteram16_bytes/2 - 8;offs >= 0;offs -= 8) |
| 191 | { |
| 192 | if (spriteram16[offs] & 0x04) /* enable */ |
| 193 | { |
| 194 | int code,color,sizex,sizey,flipx,flipy,xpos,ypos; |
| 195 | int x,y,priority,priority_mask; |
| 196 | |
| 197 | code = spriteram16[offs+1]; |
| 198 | color = (spriteram16[offs+2] & 0xf0) >> 4; |
| 199 | sizex = 1 << ((spriteram16[offs+2] & 0x03) >> 0); |
| 200 | |
| 201 | if(game_is_riot) |
| 202 | sizey = sizex; |
| 203 | else |
| 204 | sizey = 1 << ((spriteram16[offs+2] & 0x0c) >> 2); |
| 205 | |
| 206 | if (sizex >= 2) code &= ~0x01; |
| 207 | if (sizey >= 2) code &= ~0x02; |
| 208 | if (sizex >= 4) code &= ~0x04; |
| 209 | if (sizey >= 4) code &= ~0x08; |
| 210 | if (sizex >= 8) code &= ~0x10; |
| 211 | if (sizey >= 8) code &= ~0x20; |
| 212 | flipx = spriteram16[offs] & 0x01; |
| 213 | flipy = spriteram16[offs] & 0x02; |
| 214 | xpos = spriteram16[offs+4]; |
| 215 | if (xpos >= 0x8000) xpos -= 0x10000; |
| 216 | ypos = spriteram16[offs+3]; |
| 217 | if (ypos >= 0x8000) ypos -= 0x10000; |
| 218 | priority = (spriteram16[offs] & 0xc0) >> 6; |
| 219 | |
| 220 | /* bg: 1; fg:2; text: 4 */ |
| 221 | switch (priority) |
| 222 | { |
| 223 | default: |
| 224 | case 0x0: priority_mask = 0; break; |
| 225 | case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ |
| 226 | case 0x2: priority_mask = 0xf0|0xcc; break; /* obscured by foreground */ |
| 227 | case 0x3: priority_mask = 0xf0|0xcc|0xaa; break; /* obscured by bg and fg */ |
| 228 | } |
| 229 | |
| 230 | if (flipscreen) |
| 231 | { |
| 232 | flipx = !flipx; |
| 233 | flipy = !flipy; |
| 234 | } |
| 235 | |
| 236 | /* blending */ |
| 237 | if (spriteram16[offs] & 0x20) |
| 238 | { |
| 239 | color |= 0x80; |
| 240 | |
| 241 | for (y = 0;y < sizey;y++) |
| 242 | { |
| 243 | for (x = 0;x < sizex;x++) |
| 244 | { |
| 245 | int sx,sy; |
| 246 | |
| 247 | if (!flipscreen) |
| 248 | { |
| 249 | sx = xpos + 8*(flipx?(sizex-1-x):x); |
| 250 | sy = ypos + 8*(flipy?(sizey-1-y):y); |
| 251 | } else { |
| 252 | sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8); |
| 253 | sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8); |
| 254 | } |
| 255 | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 256 | code + layout[y][x], |
| 257 | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 258 | flipx,flipy, |
| 259 | sx,sy, |
| 260 | machine.priority_bitmap, priority_mask,0); |
| 261 | |
| 262 | /* wrap around x */ |
| 263 | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 264 | code + layout[y][x], |
| 265 | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 266 | flipx,flipy, |
| 267 | sx-512,sy, |
| 268 | machine.priority_bitmap, priority_mask,0); |
| 269 | |
| 270 | /* wrap around x */ |
| 271 | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 272 | code + layout[y][x], |
| 273 | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 274 | flipx,flipy, |
| 275 | sx+512,sy, |
| 276 | machine.priority_bitmap, priority_mask,0); |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; |
| 283 | |
| 284 | for (y = 0;y < sizey;y++) |
| 285 | { |
| 286 | for (x = 0;x < sizex;x++) |
| 287 | { |
| 288 | int sx,sy; |
| 289 | |
| 290 | if (!flipscreen) |
| 291 | { |
| 292 | sx = xpos + 8*(flipx?(sizex-1-x):x); |
| 293 | sy = ypos + 8*(flipy?(sizey-1-y):y); |
| 294 | } else { |
| 295 | sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8); |
| 296 | sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8); |
| 297 | } |
| 298 | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 299 | code + layout[y][x], |
| 300 | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 301 | flipx,flipy, |
| 302 | sx,sy, |
| 303 | machine.priority_bitmap, priority_mask,0); |
| 304 | |
| 305 | /* wrap around x */ |
| 306 | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 307 | code + layout[y][x], |
| 308 | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 309 | flipx,flipy, |
| 310 | sx-512,sy, |
| 311 | machine.priority_bitmap, priority_mask,0); |
| 312 | |
| 313 | /* wrap around x */ |
| 314 | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 315 | code + layout[y][x], |
| 316 | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 317 | flipx,flipy, |
| 318 | sx+512,sy, |
| 319 | machine.priority_bitmap, priority_mask,0); |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | #define NUM_SPRITES 256 |
| 328 | |
| 329 | void gaiden_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen ) |
| 330 | { |
| 331 | gfx_element *gfx = machine.gfx[3]; |
| 332 | const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram; |
| 333 | int count = NUM_SPRITES; |
| 334 | |
| 335 | /* draw all sprites from front to back */ |
| 336 | while (count--) |
| 337 | { |
| 338 | UINT32 attributes = source[0]; |
| 339 | UINT32 priority_mask; |
| 340 | int col,row; |
| 341 | |
| 342 | if (attributes & 0x04) |
| 343 | { |
| 344 | UINT32 priority = (attributes >> 6) & 3; |
| 345 | UINT32 flipx = (attributes & 1); |
| 346 | UINT32 flipy = (attributes & 2); |
| 347 | |
| 348 | UINT32 color = source[2]; |
| 349 | UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */ |
| 350 | UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */ |
| 351 | |
| 352 | /* raiga needs something like this */ |
| 353 | UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc)); |
| 354 | |
| 355 | int ypos = (source[3] + spr_offset_y) & 0x01ff; |
| 356 | int xpos = source[4] & 0x01ff; |
| 357 | |
| 358 | color = (color >> 4) & 0x0f; |
| 359 | |
| 360 | /* wraparound */ |
| 361 | if (xpos >= 256) |
| 362 | xpos -= 512; |
| 363 | if (ypos >= 256) |
| 364 | ypos -= 512; |
| 365 | |
| 366 | if (flip_screen) |
| 367 | { |
| 368 | flipx = !flipx; |
| 369 | flipy = !flipy; |
| 370 | |
| 371 | xpos = 256 - (8 * sizex) - xpos; |
| 372 | ypos = 256 - (8 * sizey) - ypos; |
| 373 | |
| 374 | if (xpos <= -256) |
| 375 | xpos += 512; |
| 376 | if (ypos <= -256) |
| 377 | ypos += 512; |
| 378 | } |
| 379 | |
| 380 | /* bg: 1; fg:2; text: 4 */ |
| 381 | switch( priority ) |
| 382 | { |
| 383 | default: |
| 384 | case 0x0: priority_mask = 0; break; |
| 385 | case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ |
| 386 | case 0x2: priority_mask = 0xf0 | 0xcc; break; /* obscured by foreground */ |
| 387 | case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */ |
| 388 | } |
| 389 | |
| 390 | |
| 391 | /* blending */ |
| 392 | if (attributes & 0x20) |
| 393 | { |
| 394 | color |= 0x80; |
| 395 | |
| 396 | for (row = 0; row < sizey; row++) |
| 397 | { |
| 398 | for (col = 0; col < sizex; col++) |
| 399 | { |
| 400 | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 401 | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 402 | |
| 403 | pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx, |
| 404 | number + layout[row][col], |
| 405 | gfx->colorbase() + color * gfx->granularity(), |
| 406 | flipx, flipy, |
| 407 | sx, sy, |
| 408 | machine.priority_bitmap, priority_mask, 0); |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | else |
| 413 | { |
| 414 | bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; |
| 415 | |
| 416 | for (row = 0; row < sizey; row++) |
| 417 | { |
| 418 | for (col = 0; col < sizex; col++) |
| 419 | { |
| 420 | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 421 | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 422 | |
| 423 | pdrawgfx_transpen_raw(bitmap, cliprect, gfx, |
| 424 | number + layout[row][col], |
| 425 | gfx->colorbase() + color * gfx->granularity(), |
| 426 | flipx, flipy, |
| 427 | sx, sy, |
| 428 | machine.priority_bitmap, priority_mask, 0); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | source -= 8; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | |
| 438 | void raiga_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen ) |
| 439 | { |
| 440 | gfx_element *gfx = machine.gfx[3]; |
| 441 | const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram; |
| 442 | int count = NUM_SPRITES; |
| 443 | |
| 444 | /* draw all sprites from front to back */ |
| 445 | while (count--) |
| 446 | { |
| 447 | UINT32 attributes = source[0]; |
| 448 | UINT32 priority_mask; |
| 449 | int col,row; |
| 450 | |
| 451 | if (attributes & 0x04) |
| 452 | { |
| 453 | UINT32 priority = (attributes >> 6) & 3; |
| 454 | UINT32 flipx = (attributes & 1); |
| 455 | UINT32 flipy = (attributes & 2); |
| 456 | |
| 457 | UINT32 color = source[2]; |
| 458 | UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */ |
| 459 | UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */ |
| 460 | |
| 461 | /* raiga needs something like this */ |
| 462 | UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc)); |
| 463 | |
| 464 | int ypos = (source[3] + spr_offset_y) & 0x01ff; |
| 465 | int xpos = source[4] & 0x01ff; |
| 466 | |
| 467 | color = (color >> 4) & 0x0f; |
| 468 | |
| 469 | /* wraparound */ |
| 470 | if (xpos >= 256) |
| 471 | xpos -= 512; |
| 472 | if (ypos >= 256) |
| 473 | ypos -= 512; |
| 474 | |
| 475 | if (flip_screen) |
| 476 | { |
| 477 | flipx = !flipx; |
| 478 | flipy = !flipy; |
| 479 | |
| 480 | xpos = 256 - (8 * sizex) - xpos; |
| 481 | ypos = 256 - (8 * sizey) - ypos; |
| 482 | |
| 483 | if (xpos <= -256) |
| 484 | xpos += 512; |
| 485 | if (ypos <= -256) |
| 486 | ypos += 512; |
| 487 | } |
| 488 | |
| 489 | /* bg: 1; fg:2; text: 4 */ |
| 490 | switch( priority ) |
| 491 | { |
| 492 | default: |
| 493 | case 0x0: priority_mask = 0; break; |
| 494 | case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ |
| 495 | case 0x2: priority_mask = 0xf0 | 0xcc; break; /* obscured by foreground */ |
| 496 | case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */ |
| 497 | } |
| 498 | |
| 499 | /* blending */ |
| 500 | if (attributes & 0x20) |
| 501 | { |
| 502 | color |= 0x80; |
| 503 | |
| 504 | for (row = 0; row < sizey; row++) |
| 505 | { |
| 506 | for (col = 0; col < sizex; col++) |
| 507 | { |
| 508 | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 509 | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 510 | |
| 511 | pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx, |
| 512 | number + layout[row][col], |
| 513 | gfx->colorbase() + color * gfx->granularity(), |
| 514 | flipx, flipy, |
| 515 | sx, sy, |
| 516 | machine.priority_bitmap, priority_mask, 0); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | else |
| 521 | { |
| 522 | bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; |
| 523 | |
| 524 | for (row = 0; row < sizey; row++) |
| 525 | { |
| 526 | for (col = 0; col < sizex; col++) |
| 527 | { |
| 528 | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 529 | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 530 | |
| 531 | pdrawgfx_transpen_raw(bitmap, cliprect, gfx, |
| 532 | number + layout[row][col], |
| 533 | gfx->colorbase() + color * gfx->granularity(), |
| 534 | flipx, flipy, |
| 535 | sx, sy, |
| 536 | machine.priority_bitmap, priority_mask, 0); |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | source -= 8; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | |
trunk/src/mame/video/galspnbl.c
| r20720 | r20721 | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | |
| 16 | | /* sprite format (see also Ninja Gaiden): |
| 17 | | * |
| 18 | | * word bit usage |
| 19 | | * --------+-fedcba9876543210-+---------------- |
| 20 | | * 0 | ---------------x | flip x |
| 21 | | * | --------------x- | flip y |
| 22 | | * | -------------x-- | enable |
| 23 | | * | ----------xx---- | priority? |
| 24 | | * | ---------x------ | flicker? |
| 25 | | * 1 | xxxxxxxxxxxxxxxx | code |
| 26 | | * 2 | --------xxxx---- | color |
| 27 | | * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 |
| 28 | | * 3 | xxxxxxxxxxxxxxxx | y position |
| 29 | | * 4 | xxxxxxxxxxxxxxxx | x position |
| 30 | | * 5,6,7| | unused |
| 31 | | */ |
| 32 | | static void draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority ) |
| 33 | | { |
| 34 | | galspnbl_state *state = machine.driver_data<galspnbl_state>(); |
| 35 | | UINT16 *spriteram = state->m_spriteram; |
| 36 | | int offs; |
| 37 | | static const UINT8 layout[8][8] = |
| 38 | | { |
| 39 | | {0,1,4,5,16,17,20,21}, |
| 40 | | {2,3,6,7,18,19,22,23}, |
| 41 | | {8,9,12,13,24,25,28,29}, |
| 42 | | {10,11,14,15,26,27,30,31}, |
| 43 | | {32,33,36,37,48,49,52,53}, |
| 44 | | {34,35,38,39,50,51,54,55}, |
| 45 | | {40,41,44,45,56,57,60,61}, |
| 46 | | {42,43,46,47,58,59,62,63} |
| 47 | | }; |
| 48 | | |
| 49 | | for (offs = (state->m_spriteram.bytes() - 16) / 2; offs >= 0; offs -= 8) |
| 50 | | { |
| 51 | | int sx, sy, code, color, size, attr, flipx, flipy; |
| 52 | | int col, row; |
| 53 | | |
| 54 | | attr = spriteram[offs]; |
| 55 | | if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (machine.primary_screen->frame_number() & 1)) |
| 56 | | // && ((attr & 0x0030) >> 4) == priority) |
| 57 | | && ((attr & 0x0020) >> 5) == priority) |
| 58 | | { |
| 59 | | code = spriteram[offs + 1]; |
| 60 | | color = spriteram[offs + 2]; |
| 61 | | size = 1 << (color & 0x0003); // 1,2,4,8 |
| 62 | | color = (color & 0x00f0) >> 4; |
| 63 | | // sx = spriteram[offs + 4] + screenscroll; |
| 64 | | sx = spriteram[offs + 4]; |
| 65 | | sy = spriteram[offs + 3]; |
| 66 | | flipx = attr & 0x0001; |
| 67 | | flipy = attr & 0x0002; |
| 68 | | |
| 69 | | for (row = 0; row < size; row++) |
| 70 | | { |
| 71 | | for (col = 0; col < size; col++) |
| 72 | | { |
| 73 | | int x = sx + 8 * (flipx ? (size - 1 - col) : col); |
| 74 | | int y = sy + 8 * (flipy ? (size - 1 - row) : row); |
| 75 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[1], |
| 76 | | code + layout[row][col], |
| 77 | | color, |
| 78 | | flipx,flipy, |
| 79 | | x,y,0); |
| 80 | | } |
| 81 | | } |
| 82 | | } |
| 83 | | } |
| 84 | | } |
| 85 | | |
| 86 | | |
| 87 | 16 | static void draw_background( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 88 | 17 | { |
| 89 | 18 | galspnbl_state *state = machine.driver_data<galspnbl_state>(); |
| r20720 | r20721 | |
| 107 | 36 | |
| 108 | 37 | draw_background(machine(), bitmap, cliprect); |
| 109 | 38 | |
| 110 | | draw_sprites(machine(), bitmap, cliprect, 0); |
| 39 | galspnbl_draw_sprites(machine(), bitmap, cliprect, 0, m_spriteram, m_spriteram.bytes()); |
| 111 | 40 | |
| 112 | 41 | for (offs = 0; offs < 0x1000 / 2; offs++) |
| 113 | 42 | { |
| r20720 | r20721 | |
| 131 | 60 | } |
| 132 | 61 | } |
| 133 | 62 | |
| 134 | | draw_sprites(machine(), bitmap, cliprect, 1); |
| 63 | galspnbl_draw_sprites(machine(), bitmap, cliprect, 1, m_spriteram, m_spriteram.bytes()); |
| 135 | 64 | return 0; |
| 136 | 65 | } |
trunk/src/mame/video/gaiden.c
| r20720 | r20721 | |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | // dragon bowl uses a bootleg format |
| 314 | 315 | /* sprite format: |
| 315 | 316 | * |
| 316 | 317 | * word bit usage |
| 317 | 318 | * --------+-fedcba9876543210-+---------------- |
| 318 | | * 0 | ---------------x | flip x |
| 319 | | * | --------------x- | flip y |
| 320 | | * | -------------x-- | enable |
| 321 | | * | ----------x----- | blend |
| 322 | | * | --------xx------ | sprite-tile priority |
| 323 | | * 1 | xxxxxxxxxxxxxxxx | number |
| 324 | | * 2 | --------xxxx---- | palette |
| 325 | | * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 |
| 326 | | * 3 | xxxxxxxxxxxxxxxx | y position |
| 327 | | * 4 | xxxxxxxxxxxxxxxx | x position |
| 328 | | * 5,6,7| | unused |
| 329 | | */ |
| 330 | | |
| 331 | | #define NUM_SPRITES 256 |
| 332 | | |
| 333 | | static void gaiden_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect ) |
| 334 | | { |
| 335 | | static const UINT8 layout[8][8] = |
| 336 | | { |
| 337 | | { 0, 1, 4, 5,16,17,20,21}, |
| 338 | | { 2, 3, 6, 7,18,19,22,23}, |
| 339 | | { 8, 9,12,13,24,25,28,29}, |
| 340 | | {10,11,14,15,26,27,30,31}, |
| 341 | | {32,33,36,37,48,49,52,53}, |
| 342 | | {34,35,38,39,50,51,54,55}, |
| 343 | | {40,41,44,45,56,57,60,61}, |
| 344 | | {42,43,46,47,58,59,62,63} |
| 345 | | }; |
| 346 | | |
| 347 | | gaiden_state *state = machine.driver_data<gaiden_state>(); |
| 348 | | gfx_element *gfx = machine.gfx[3]; |
| 349 | | const UINT16 *source = (NUM_SPRITES - 1) * 8 + state->m_spriteram; |
| 350 | | int count = NUM_SPRITES; |
| 351 | | |
| 352 | | /* draw all sprites from front to back */ |
| 353 | | while (count--) |
| 354 | | { |
| 355 | | UINT32 attributes = source[0]; |
| 356 | | UINT32 priority_mask; |
| 357 | | int col,row; |
| 358 | | |
| 359 | | if (attributes & 0x04) |
| 360 | | { |
| 361 | | UINT32 priority = (attributes >> 6) & 3; |
| 362 | | UINT32 flipx = (attributes & 1); |
| 363 | | UINT32 flipy = (attributes & 2); |
| 364 | | |
| 365 | | UINT32 color = source[2]; |
| 366 | | UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */ |
| 367 | | UINT32 sizey = 1 << ((color >> state->m_sprite_sizey) & 3); /* 1,2,4,8 */ |
| 368 | | |
| 369 | | /* raiga needs something like this */ |
| 370 | | UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc)); |
| 371 | | |
| 372 | | int ypos = (source[3] + state->m_spr_offset_y) & 0x01ff; |
| 373 | | int xpos = source[4] & 0x01ff; |
| 374 | | |
| 375 | | color = (color >> 4) & 0x0f; |
| 376 | | |
| 377 | | /* wraparound */ |
| 378 | | if (xpos >= 256) |
| 379 | | xpos -= 512; |
| 380 | | if (ypos >= 256) |
| 381 | | ypos -= 512; |
| 382 | | |
| 383 | | if (state->flip_screen()) |
| 384 | | { |
| 385 | | flipx = !flipx; |
| 386 | | flipy = !flipy; |
| 387 | | |
| 388 | | xpos = 256 - (8 * sizex) - xpos; |
| 389 | | ypos = 256 - (8 * sizey) - ypos; |
| 390 | | |
| 391 | | if (xpos <= -256) |
| 392 | | xpos += 512; |
| 393 | | if (ypos <= -256) |
| 394 | | ypos += 512; |
| 395 | | } |
| 396 | | |
| 397 | | /* bg: 1; fg:2; text: 4 */ |
| 398 | | switch( priority ) |
| 399 | | { |
| 400 | | default: |
| 401 | | case 0x0: priority_mask = 0; break; |
| 402 | | case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ |
| 403 | | case 0x2: priority_mask = 0xf0 | 0xcc; break; /* obscured by foreground */ |
| 404 | | case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */ |
| 405 | | } |
| 406 | | |
| 407 | | |
| 408 | | /* blending */ |
| 409 | | if (attributes & 0x20) |
| 410 | | { |
| 411 | | color |= 0x80; |
| 412 | | |
| 413 | | for (row = 0; row < sizey; row++) |
| 414 | | { |
| 415 | | for (col = 0; col < sizex; col++) |
| 416 | | { |
| 417 | | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 418 | | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 419 | | |
| 420 | | pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx, |
| 421 | | number + layout[row][col], |
| 422 | | gfx->colorbase() + color * gfx->granularity(), |
| 423 | | flipx, flipy, |
| 424 | | sx, sy, |
| 425 | | machine.priority_bitmap, priority_mask, 0); |
| 426 | | } |
| 427 | | } |
| 428 | | } |
| 429 | | else |
| 430 | | { |
| 431 | | bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; |
| 432 | | |
| 433 | | for (row = 0; row < sizey; row++) |
| 434 | | { |
| 435 | | for (col = 0; col < sizex; col++) |
| 436 | | { |
| 437 | | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 438 | | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 439 | | |
| 440 | | pdrawgfx_transpen_raw(bitmap, cliprect, gfx, |
| 441 | | number + layout[row][col], |
| 442 | | gfx->colorbase() + color * gfx->granularity(), |
| 443 | | flipx, flipy, |
| 444 | | sx, sy, |
| 445 | | machine.priority_bitmap, priority_mask, 0); |
| 446 | | } |
| 447 | | } |
| 448 | | } |
| 449 | | } |
| 450 | | source -= 8; |
| 451 | | } |
| 452 | | } |
| 453 | | |
| 454 | | |
| 455 | | static void raiga_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect ) |
| 456 | | { |
| 457 | | static const UINT8 layout[8][8] = |
| 458 | | { |
| 459 | | { 0, 1, 4, 5,16,17,20,21}, |
| 460 | | { 2, 3, 6, 7,18,19,22,23}, |
| 461 | | { 8, 9,12,13,24,25,28,29}, |
| 462 | | {10,11,14,15,26,27,30,31}, |
| 463 | | {32,33,36,37,48,49,52,53}, |
| 464 | | {34,35,38,39,50,51,54,55}, |
| 465 | | {40,41,44,45,56,57,60,61}, |
| 466 | | {42,43,46,47,58,59,62,63} |
| 467 | | }; |
| 468 | | |
| 469 | | gaiden_state *state = machine.driver_data<gaiden_state>(); |
| 470 | | gfx_element *gfx = machine.gfx[3]; |
| 471 | | const UINT16 *source = (NUM_SPRITES - 1) * 8 + state->m_spriteram; |
| 472 | | int count = NUM_SPRITES; |
| 473 | | |
| 474 | | /* draw all sprites from front to back */ |
| 475 | | while (count--) |
| 476 | | { |
| 477 | | UINT32 attributes = source[0]; |
| 478 | | UINT32 priority_mask; |
| 479 | | int col,row; |
| 480 | | |
| 481 | | if (attributes & 0x04) |
| 482 | | { |
| 483 | | UINT32 priority = (attributes >> 6) & 3; |
| 484 | | UINT32 flipx = (attributes & 1); |
| 485 | | UINT32 flipy = (attributes & 2); |
| 486 | | |
| 487 | | UINT32 color = source[2]; |
| 488 | | UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */ |
| 489 | | UINT32 sizey = 1 << ((color >> state->m_sprite_sizey) & 3); /* 1,2,4,8 */ |
| 490 | | |
| 491 | | /* raiga needs something like this */ |
| 492 | | UINT32 number = (source[1] & (sizex > 2 ? 0x7ff8 : 0x7ffc)); |
| 493 | | |
| 494 | | int ypos = (source[3] + state->m_spr_offset_y) & 0x01ff; |
| 495 | | int xpos = source[4] & 0x01ff; |
| 496 | | |
| 497 | | color = (color >> 4) & 0x0f; |
| 498 | | |
| 499 | | /* wraparound */ |
| 500 | | if (xpos >= 256) |
| 501 | | xpos -= 512; |
| 502 | | if (ypos >= 256) |
| 503 | | ypos -= 512; |
| 504 | | |
| 505 | | if (state->flip_screen()) |
| 506 | | { |
| 507 | | flipx = !flipx; |
| 508 | | flipy = !flipy; |
| 509 | | |
| 510 | | xpos = 256 - (8 * sizex) - xpos; |
| 511 | | ypos = 256 - (8 * sizey) - ypos; |
| 512 | | |
| 513 | | if (xpos <= -256) |
| 514 | | xpos += 512; |
| 515 | | if (ypos <= -256) |
| 516 | | ypos += 512; |
| 517 | | } |
| 518 | | |
| 519 | | /* bg: 1; fg:2; text: 4 */ |
| 520 | | switch( priority ) |
| 521 | | { |
| 522 | | default: |
| 523 | | case 0x0: priority_mask = 0; break; |
| 524 | | case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ |
| 525 | | case 0x2: priority_mask = 0xf0 | 0xcc; break; /* obscured by foreground */ |
| 526 | | case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */ |
| 527 | | } |
| 528 | | |
| 529 | | /* blending */ |
| 530 | | if (attributes & 0x20) |
| 531 | | { |
| 532 | | color |= 0x80; |
| 533 | | |
| 534 | | for (row = 0; row < sizey; row++) |
| 535 | | { |
| 536 | | for (col = 0; col < sizex; col++) |
| 537 | | { |
| 538 | | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 539 | | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 540 | | |
| 541 | | pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx, |
| 542 | | number + layout[row][col], |
| 543 | | gfx->colorbase() + color * gfx->granularity(), |
| 544 | | flipx, flipy, |
| 545 | | sx, sy, |
| 546 | | machine.priority_bitmap, priority_mask, 0); |
| 547 | | } |
| 548 | | } |
| 549 | | } |
| 550 | | else |
| 551 | | { |
| 552 | | bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; |
| 553 | | |
| 554 | | for (row = 0; row < sizey; row++) |
| 555 | | { |
| 556 | | for (col = 0; col < sizex; col++) |
| 557 | | { |
| 558 | | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 559 | | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 560 | | |
| 561 | | pdrawgfx_transpen_raw(bitmap, cliprect, gfx, |
| 562 | | number + layout[row][col], |
| 563 | | gfx->colorbase() + color * gfx->granularity(), |
| 564 | | flipx, flipy, |
| 565 | | sx, sy, |
| 566 | | machine.priority_bitmap, priority_mask, 0); |
| 567 | | } |
| 568 | | } |
| 569 | | } |
| 570 | | } |
| 571 | | |
| 572 | | source -= 8; |
| 573 | | } |
| 574 | | } |
| 575 | | |
| 576 | | |
| 577 | | /* sprite format: |
| 578 | | * |
| 579 | | * word bit usage |
| 580 | | * --------+-fedcba9876543210-+---------------- |
| 581 | 319 | * 0 | --------xxxxxxxx | sprite code (lower bits) |
| 582 | 320 | * | ---xxxxx-------- | unused ? |
| 583 | 321 | * 1 | --------xxxxxxxx | y position |
| r20720 | r20721 | |
| 650 | 388 | m_text_layer->draw(m_tile_bitmap_fg, cliprect, 0, 4); |
| 651 | 389 | |
| 652 | 390 | /* draw sprites into a 16-bit bitmap */ |
| 653 | | gaiden_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect); |
| 391 | gaiden_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen()); |
| 654 | 392 | |
| 655 | 393 | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 656 | 394 | blendbitmaps(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect); |
| r20720 | r20721 | |
| 675 | 413 | m_text_layer->draw(m_tile_bitmap_fg, cliprect, 0, 4); |
| 676 | 414 | |
| 677 | 415 | /* draw sprites into a 16-bit bitmap */ |
| 678 | | raiga_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect); |
| 416 | raiga_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen()); |
| 679 | 417 | |
| 680 | 418 | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 681 | 419 | blendbitmaps(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect); |
trunk/src/mame/video/tecmo16.c
| r20720 | r20721 | |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | | static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect) |
| 308 | | { |
| 309 | | tecmo16_state *state = machine.driver_data<tecmo16_state>(); |
| 310 | | UINT16 *spriteram16 = state->m_spriteram; |
| 311 | | int offs; |
| 312 | | static const UINT8 layout[8][8] = |
| 313 | | { |
| 314 | | { 0, 1, 4, 5,16,17,20,21}, |
| 315 | | { 2, 3, 6, 7,18,19,22,23}, |
| 316 | | { 8, 9,12,13,24,25,28,29}, |
| 317 | | {10,11,14,15,26,27,30,31}, |
| 318 | | {32,33,36,37,48,49,52,53}, |
| 319 | | {34,35,38,39,50,51,54,55}, |
| 320 | | {40,41,44,45,56,57,60,61}, |
| 321 | | {42,43,46,47,58,59,62,63} |
| 322 | | }; |
| 323 | | |
| 324 | | bitmap_ind16 &bitmap = bitmap_bg; |
| 325 | | |
| 326 | | for (offs = state->m_spriteram.bytes()/2 - 8;offs >= 0;offs -= 8) |
| 327 | | { |
| 328 | | if (spriteram16[offs] & 0x04) /* enable */ |
| 329 | | { |
| 330 | | int code,color,sizex,sizey,flipx,flipy,xpos,ypos; |
| 331 | | int x,y,priority,priority_mask; |
| 332 | | |
| 333 | | code = spriteram16[offs+1]; |
| 334 | | color = (spriteram16[offs+2] & 0xf0) >> 4; |
| 335 | | sizex = 1 << ((spriteram16[offs+2] & 0x03) >> 0); |
| 336 | | |
| 337 | | if(state->m_game_is_riot) |
| 338 | | sizey = sizex; |
| 339 | | else |
| 340 | | sizey = 1 << ((spriteram16[offs+2] & 0x0c) >> 2); |
| 341 | | |
| 342 | | if (sizex >= 2) code &= ~0x01; |
| 343 | | if (sizey >= 2) code &= ~0x02; |
| 344 | | if (sizex >= 4) code &= ~0x04; |
| 345 | | if (sizey >= 4) code &= ~0x08; |
| 346 | | if (sizex >= 8) code &= ~0x10; |
| 347 | | if (sizey >= 8) code &= ~0x20; |
| 348 | | flipx = spriteram16[offs] & 0x01; |
| 349 | | flipy = spriteram16[offs] & 0x02; |
| 350 | | xpos = spriteram16[offs+4]; |
| 351 | | if (xpos >= 0x8000) xpos -= 0x10000; |
| 352 | | ypos = spriteram16[offs+3]; |
| 353 | | if (ypos >= 0x8000) ypos -= 0x10000; |
| 354 | | priority = (spriteram16[offs] & 0xc0) >> 6; |
| 355 | | |
| 356 | | /* bg: 1; fg:2; text: 4 */ |
| 357 | | switch (priority) |
| 358 | | { |
| 359 | | default: |
| 360 | | case 0x0: priority_mask = 0; break; |
| 361 | | case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ |
| 362 | | case 0x2: priority_mask = 0xf0|0xcc; break; /* obscured by foreground */ |
| 363 | | case 0x3: priority_mask = 0xf0|0xcc|0xaa; break; /* obscured by bg and fg */ |
| 364 | | } |
| 365 | | |
| 366 | | if (state->m_flipscreen) |
| 367 | | { |
| 368 | | flipx = !flipx; |
| 369 | | flipy = !flipy; |
| 370 | | } |
| 371 | | |
| 372 | | /* blending */ |
| 373 | | if (spriteram16[offs] & 0x20) |
| 374 | | { |
| 375 | | color |= 0x80; |
| 376 | | |
| 377 | | for (y = 0;y < sizey;y++) |
| 378 | | { |
| 379 | | for (x = 0;x < sizex;x++) |
| 380 | | { |
| 381 | | int sx,sy; |
| 382 | | |
| 383 | | if (!state->m_flipscreen) |
| 384 | | { |
| 385 | | sx = xpos + 8*(flipx?(sizex-1-x):x); |
| 386 | | sy = ypos + 8*(flipy?(sizey-1-y):y); |
| 387 | | } else { |
| 388 | | sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8); |
| 389 | | sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8); |
| 390 | | } |
| 391 | | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 392 | | code + layout[y][x], |
| 393 | | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 394 | | flipx,flipy, |
| 395 | | sx,sy, |
| 396 | | machine.priority_bitmap, priority_mask,0); |
| 397 | | |
| 398 | | /* wrap around x */ |
| 399 | | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 400 | | code + layout[y][x], |
| 401 | | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 402 | | flipx,flipy, |
| 403 | | sx-512,sy, |
| 404 | | machine.priority_bitmap, priority_mask,0); |
| 405 | | |
| 406 | | /* wrap around x */ |
| 407 | | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 408 | | code + layout[y][x], |
| 409 | | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 410 | | flipx,flipy, |
| 411 | | sx+512,sy, |
| 412 | | machine.priority_bitmap, priority_mask,0); |
| 413 | | } |
| 414 | | } |
| 415 | | } |
| 416 | | else |
| 417 | | { |
| 418 | | bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; |
| 419 | | |
| 420 | | for (y = 0;y < sizey;y++) |
| 421 | | { |
| 422 | | for (x = 0;x < sizex;x++) |
| 423 | | { |
| 424 | | int sx,sy; |
| 425 | | |
| 426 | | if (!state->m_flipscreen) |
| 427 | | { |
| 428 | | sx = xpos + 8*(flipx?(sizex-1-x):x); |
| 429 | | sy = ypos + 8*(flipy?(sizey-1-y):y); |
| 430 | | } else { |
| 431 | | sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8); |
| 432 | | sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8); |
| 433 | | } |
| 434 | | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 435 | | code + layout[y][x], |
| 436 | | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 437 | | flipx,flipy, |
| 438 | | sx,sy, |
| 439 | | machine.priority_bitmap, priority_mask,0); |
| 440 | | |
| 441 | | /* wrap around x */ |
| 442 | | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 443 | | code + layout[y][x], |
| 444 | | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 445 | | flipx,flipy, |
| 446 | | sx-512,sy, |
| 447 | | machine.priority_bitmap, priority_mask,0); |
| 448 | | |
| 449 | | /* wrap around x */ |
| 450 | | pdrawgfx_transpen_raw(bitmap,cliprect,machine.gfx[2], |
| 451 | | code + layout[y][x], |
| 452 | | machine.gfx[2]->colorbase() + color * machine.gfx[2]->granularity(), |
| 453 | | flipx,flipy, |
| 454 | | sx+512,sy, |
| 455 | | machine.priority_bitmap, priority_mask,0); |
| 456 | | } |
| 457 | | } |
| 458 | | } |
| 459 | | } |
| 460 | | } |
| 461 | | } |
| 462 | | |
| 463 | 307 | /******************************************************************************/ |
| 464 | 308 | |
| 465 | 309 | UINT32 tecmo16_state::screen_update_tecmo16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| r20720 | r20721 | |
| 479 | 323 | m_tx_tilemap->draw(m_tile_bitmap_fg, cliprect, 0, 4); |
| 480 | 324 | |
| 481 | 325 | /* draw sprites into a 16-bit bitmap */ |
| 482 | | draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect); |
| 326 | tecmo16_draw_sprites(machine(), m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_spriteram.bytes(), m_game_is_riot, m_flipscreen); |
| 483 | 327 | |
| 484 | 328 | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 485 | 329 | blendbitmaps(machine(), bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect); |