Previous 199869 Revisions Next

r21825 Wednesday 13th March, 2013 at 09:37:17 UTC by David Haywood
popobear - stop abusing 8-bit region for vram
[src/mame/drivers]popobear.c

trunk/src/mame/drivers/popobear.c
r21824r21825
105105   required_shared_ptr<UINT16> m_spr;
106106   required_shared_ptr<UINT16> m_vregs;
107107
108   UINT8* m_vram;
109   UINT8* m_vram_rearranged;
108   UINT16* m_vram;
109   UINT16* m_vram_rearranged;
110110
111111   int tilemap_base[4];
112112   int tilemap_size[4];
r21824r21825
126126   TILE_GET_INFO_MEMBER(get_popobear_bg2_tile_info);
127127   TILE_GET_INFO_MEMBER(get_popobear_bg3_tile_info);
128128
129   // why are we using 8-bit anyway?
130   DECLARE_WRITE8_MEMBER(popo_vram_w)
129   DECLARE_WRITE16_MEMBER(popo_vram_w)
131130   {
132      m_vram[offset^1] = data;
131      COMBINE_DATA(&m_vram[offset]);
133132
134133      // 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 */
136135   
137      19,18,17,16,15,14,13,
136      18,17,16,15,14,13,12,
138137     
139      9,8,7,6,5,4,3,
138      8,7,6,5,4,3,2,
140139
141      12,11,10, /* y tile address bits */
140      11,10,9, /* y tile address bits */
142141     
143      2,1,0 /* x tile address bits */);
142      1,0 /* x tile address bits */);
144143
145144
146145
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);
149148
150149      // unfortunately tilemaps and tilegfx share the same ram so we're always dirty if we write to RAM
151150      m_bg_tilemap[0]->mark_all_dirty();
r21824r21825
154153      m_bg_tilemap[3]->mark_all_dirty();
155154
156155   }
157   DECLARE_READ8_MEMBER(popo_vram_r) { return m_vram[offset^1]; }
156   DECLARE_READ16_MEMBER(popo_vram_r) { return m_vram[offset]; }
158157
159158};
160159
r21824r21825
165164   0x4000,
166165   8,
167166   { 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 },
169168   { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64 },
170169   8*64
171170};
r21824r21825
174173TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg0_tile_info)
175174{
176175   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];
178177   SET_TILE_INFO_MEMBER(0, tileno, 0, 0);
179178}
180179
181180TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg1_tile_info)
182181{
183182   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];
185184   SET_TILE_INFO_MEMBER(0, tileno, 0, 0);
186185}
187186
188187TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg2_tile_info)
189188{
190189   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];
192191   SET_TILE_INFO_MEMBER(0, tileno, 0, 0);
193192}
194193
195194TILE_GET_INFO_MEMBER(popobear_state::get_popobear_bg3_tile_info)
196195{
197196   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];
199198   SET_TILE_INFO_MEMBER(0, tileno, 0, 0);
200199}
201200
r21824r21825
211210
212211   assert(m_gfx_index != MAX_GFX_ELEMENTS);
213212
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);
216215
217216
218217   /* create the char set (gfx will then be updated dynamically from RAM) */
r21824r21825
353352   ADDRESS_MAP_UNMAP_HIGH
354353   AM_RANGE(0x000000, 0x03ffff) AM_ROM
355354   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
358357             
359358
360359   /* Most if not all of these are vregs */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team