trunk/src/mame/drivers/popobear.c
| r21824 | r21825 | |
| 105 | 105 | required_shared_ptr<UINT16> m_spr; |
| 106 | 106 | required_shared_ptr<UINT16> m_vregs; |
| 107 | 107 | |
| 108 | | UINT8* m_vram; |
| 109 | | UINT8* m_vram_rearranged; |
| 108 | UINT16* m_vram; |
| 109 | UINT16* m_vram_rearranged; |
| 110 | 110 | |
| 111 | 111 | int tilemap_base[4]; |
| 112 | 112 | int tilemap_size[4]; |
| r21824 | r21825 | |
| 126 | 126 | TILE_GET_INFO_MEMBER(get_popobear_bg2_tile_info); |
| 127 | 127 | TILE_GET_INFO_MEMBER(get_popobear_bg3_tile_info); |
| 128 | 128 | |
| 129 | | // why are we using 8-bit anyway? |
| 130 | | DECLARE_WRITE8_MEMBER(popo_vram_w) |
| 129 | DECLARE_WRITE16_MEMBER(popo_vram_w) |
| 131 | 130 | { |
| 132 | | m_vram[offset^1] = data; |
| 131 | COMBINE_DATA(&m_vram[offset]); |
| 133 | 132 | |
| 134 | 133 | // the graphic data for the tiles is in a strange order, rearrange it so that we can use it as tiles.. |
| 135 | | int swapped_offset = BITSWAP32(offset, /* unused bits */ 31,30,29,28,27,26,25,24,23,22,21,20, /* end unused bits */ |
| 134 | int swapped_offset = BITSWAP32(offset, /* unused bits */ 31,30,29,28,27,26,25,24,23,22,21,20,19, /* end unused bits */ |
| 136 | 135 | |
| 137 | | 19,18,17,16,15,14,13, |
| 136 | 18,17,16,15,14,13,12, |
| 138 | 137 | |
| 139 | | 9,8,7,6,5,4,3, |
| 138 | 8,7,6,5,4,3,2, |
| 140 | 139 | |
| 141 | | 12,11,10, /* y tile address bits */ |
| 140 | 11,10,9, /* y tile address bits */ |
| 142 | 141 | |
| 143 | | 2,1,0 /* x tile address bits */); |
| 142 | 1,0 /* x tile address bits */); |
| 144 | 143 | |
| 145 | 144 | |
| 146 | 145 | |
| 147 | | m_vram_rearranged[swapped_offset] = data; |
| 148 | | machine().gfx[m_gfx_index]->mark_dirty((swapped_offset^1)/2); |
| 146 | COMBINE_DATA(&m_vram_rearranged[swapped_offset]); |
| 147 | machine().gfx[m_gfx_index]->mark_dirty((swapped_offset)/32); |
| 149 | 148 | |
| 150 | 149 | // unfortunately tilemaps and tilegfx share the same ram so we're always dirty if we write to RAM |
| 151 | 150 | m_bg_tilemap[0]->mark_all_dirty(); |
| r21824 | r21825 | |
| 154 | 153 | m_bg_tilemap[3]->mark_all_dirty(); |
| 155 | 154 | |
| 156 | 155 | } |
| 157 | | DECLARE_READ8_MEMBER(popo_vram_r) { return m_vram[offset^1]; } |
| 156 | DECLARE_READ16_MEMBER(popo_vram_r) { return m_vram[offset]; } |
| 158 | 157 | |
| 159 | 158 | }; |
| 160 | 159 | |
| r21824 | r21825 | |
| 165 | 164 | 0x4000, |
| 166 | 165 | 8, |
| 167 | 166 | { 0,1,2,3,4,5,6,7 }, |
| 168 | | { 0,8,16,24,32,40,48,56 }, |
| 167 | { 8,0,24,16,40,32,56,48 }, |
| 169 | 168 | { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64 }, |
| 170 | 169 | 8*64 |
| 171 | 170 | }; |
| r21824 | r21825 | |
| 174 | 173 | TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg0_tile_info) |
| 175 | 174 | { |
| 176 | 175 | int base = tilemap_base[0]; |
| 177 | | int tileno = (m_vram[base + tile_index*2 + 1]<<8) | m_vram[base + tile_index*2 + 0]; |
| 176 | int tileno = m_vram[base/2 + tile_index]; |
| 178 | 177 | SET_TILE_INFO_MEMBER(0, tileno, 0, 0); |
| 179 | 178 | } |
| 180 | 179 | |
| 181 | 180 | TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg1_tile_info) |
| 182 | 181 | { |
| 183 | 182 | int base = tilemap_base[1]; |
| 184 | | int tileno = (m_vram[base + tile_index*2 + 1]<<8) | m_vram[base + tile_index*2 + 0]; |
| 183 | int tileno = m_vram[base/2 + tile_index]; |
| 185 | 184 | SET_TILE_INFO_MEMBER(0, tileno, 0, 0); |
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 | TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg2_tile_info) |
| 189 | 188 | { |
| 190 | 189 | int base = tilemap_base[2]; |
| 191 | | int tileno = (m_vram[base + tile_index*2 + 1]<<8) | m_vram[base + tile_index*2 + 0]; |
| 190 | int tileno = m_vram[base/2 + tile_index]; |
| 192 | 191 | SET_TILE_INFO_MEMBER(0, tileno, 0, 0); |
| 193 | 192 | } |
| 194 | 193 | |
| 195 | 194 | TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg3_tile_info) |
| 196 | 195 | { |
| 197 | 196 | int base = tilemap_base[3]; |
| 198 | | int tileno = (m_vram[base + tile_index*2 + 1]<<8) | m_vram[base + tile_index*2 + 0]; |
| 197 | int tileno = m_vram[base/2 + tile_index]; |
| 199 | 198 | SET_TILE_INFO_MEMBER(0, tileno, 0, 0); |
| 200 | 199 | } |
| 201 | 200 | |
| r21824 | r21825 | |
| 211 | 210 | |
| 212 | 211 | assert(m_gfx_index != MAX_GFX_ELEMENTS); |
| 213 | 212 | |
| 214 | | m_vram = auto_alloc_array_clear(machine(), UINT8, 0x100000); |
| 215 | | m_vram_rearranged = auto_alloc_array_clear(machine(), UINT8, 0x100000); |
| 213 | m_vram = auto_alloc_array_clear(machine(), UINT16, 0x100000/2); |
| 214 | m_vram_rearranged = auto_alloc_array_clear(machine(), UINT16, 0x100000/2); |
| 216 | 215 | |
| 217 | 216 | |
| 218 | 217 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| r21824 | r21825 | |
| 353 | 352 | ADDRESS_MAP_UNMAP_HIGH |
| 354 | 353 | AM_RANGE(0x000000, 0x03ffff) AM_ROM |
| 355 | 354 | AM_RANGE(0x210000, 0x21ffff) AM_RAM |
| 356 | | AM_RANGE(0x280000, 0x2fffff) AM_RAM AM_SHARE("spr") // unknown boundaries, 0x2ff800 contains a sprite list |
| 357 | | AM_RANGE(0x300000, 0x3fffff) AM_READWRITE8( popo_vram_r, popo_vram_w, 0xffff ) |
| 355 | AM_RANGE(0x280000, 0x2fffff) AM_RAM AM_SHARE("spr") // unknown boundaries, 0x2ff800 contains a sprite list, lower area = sprite gfx |
| 356 | AM_RANGE(0x300000, 0x3fffff) AM_READWRITE( popo_vram_r, popo_vram_w ) // tile definitions + tilemaps |
| 358 | 357 | |
| 359 | 358 | |
| 360 | 359 | /* Most if not all of these are vregs */ |