trunk/src/mess/drivers/casloopy.c
| r21612 | r21613 | |
| 161 | 161 | m_bios_rom(*this, "bios_rom"){ } |
| 162 | 162 | |
| 163 | 163 | required_shared_ptr<UINT32> m_bios_rom; |
| 164 | UINT16 *m_paletteram; |
| 165 | UINT8 *m_vram; |
| 166 | int m_gfx_index; |
| 164 | 167 | DECLARE_DRIVER_INIT(casloopy); |
| 165 | 168 | virtual void machine_start(); |
| 166 | 169 | virtual void machine_reset(); |
| 167 | 170 | virtual void video_start(); |
| 168 | 171 | UINT32 screen_update_casloopy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 172 | DECLARE_READ16_MEMBER(casloopy_vregs_r); |
| 173 | DECLARE_WRITE16_MEMBER(casloopy_vregs_w); |
| 174 | DECLARE_READ16_MEMBER(casloopy_pal_r); |
| 175 | DECLARE_WRITE16_MEMBER(casloopy_pal_w); |
| 176 | DECLARE_READ8_MEMBER(casloopy_vram_r); |
| 177 | DECLARE_WRITE8_MEMBER(casloopy_vram_w); |
| 169 | 178 | }; |
| 170 | 179 | |
| 171 | 180 | |
| 181 | static const gfx_layout casloopy_tile_layout = |
| 182 | { |
| 183 | 8,8, |
| 184 | 0x400, |
| 185 | 4, |
| 186 | { 0, 1, 2, 3 }, |
| 187 | { STEP8(0, 4) }, |
| 188 | { STEP8(0, 4*8) }, |
| 189 | 4*8*8 |
| 190 | }; |
| 172 | 191 | |
| 173 | 192 | void casloopy_state::video_start() |
| 174 | 193 | { |
| 194 | /* TODO: proper sizes */ |
| 195 | m_paletteram = auto_alloc_array(machine(), UINT16, 0x1000); |
| 196 | m_vram = auto_alloc_array(machine(), UINT8, 0x4000); |
| 197 | |
| 198 | for (m_gfx_index = 0; m_gfx_index < MAX_GFX_ELEMENTS; m_gfx_index++) |
| 199 | if (machine().gfx[m_gfx_index] == 0) |
| 200 | break; |
| 201 | |
| 202 | machine().gfx[m_gfx_index] = auto_alloc(machine(), gfx_element(machine(), casloopy_tile_layout, m_vram, 0x10, 0)); |
| 175 | 203 | } |
| 176 | 204 | |
| 177 | 205 | UINT32 casloopy_state::screen_update_casloopy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 178 | 206 | { |
| 207 | gfx_element *gfx = machine().gfx[m_gfx_index]; |
| 208 | int x,y; |
| 209 | int count; |
| 210 | |
| 211 | count = 0; |
| 212 | |
| 213 | for (y=0;y<32;y++) |
| 214 | { |
| 215 | for (x=0;x<32;x++) |
| 216 | { |
| 217 | UINT16 tile = (m_vram[count+1])|(m_vram[count]<<8); |
| 218 | |
| 219 | tile &= 0x3ff; //??? |
| 220 | tile |= 0x100; |
| 221 | |
| 222 | drawgfx_opaque(bitmap,cliprect,gfx,tile,7,0,0,x*8,y*8); |
| 223 | |
| 224 | count+=2; |
| 225 | } |
| 226 | } |
| 227 | |
| 179 | 228 | return 0; |
| 180 | 229 | } |
| 181 | 230 | |
| 231 | READ16_MEMBER(casloopy_state::casloopy_vregs_r) |
| 232 | { |
| 233 | if(offset == 4/2) |
| 234 | { |
| 235 | return (machine().primary_screen->vblank() << 8); /*| (machine().primary_screen->vpos() & 0xff);*/ |
| 236 | } |
| 237 | |
| 238 | printf("%08x\n",offset*2); |
| 239 | |
| 240 | return 0xffff; |
| 241 | } |
| 242 | |
| 243 | WRITE16_MEMBER(casloopy_state::casloopy_vregs_w) |
| 244 | { |
| 245 | printf("%08x %08x\n",offset*2,data); |
| 246 | } |
| 247 | |
| 248 | READ16_MEMBER(casloopy_state::casloopy_pal_r) |
| 249 | { |
| 250 | return m_paletteram[offset]; |
| 251 | } |
| 252 | |
| 253 | WRITE16_MEMBER(casloopy_state::casloopy_pal_w) |
| 254 | { |
| 255 | int r,g,b; |
| 256 | COMBINE_DATA(&m_paletteram[offset]); |
| 257 | |
| 258 | b = ((m_paletteram[offset])&0x001f)>>0; |
| 259 | g = ((m_paletteram[offset])&0x03e0)>>5; |
| 260 | r = ((m_paletteram[offset])&0x7c00)>>10; |
| 261 | |
| 262 | palette_set_color_rgb(machine(), offset, pal5bit(r), pal5bit(g), pal5bit(b)); |
| 263 | } |
| 264 | |
| 265 | READ8_MEMBER(casloopy_state::casloopy_vram_r) |
| 266 | { |
| 267 | return m_vram[offset]; |
| 268 | } |
| 269 | |
| 270 | WRITE8_MEMBER(casloopy_state::casloopy_vram_w) |
| 271 | { |
| 272 | m_vram[offset] = data; |
| 273 | |
| 274 | machine().gfx[m_gfx_index]->mark_dirty(offset/256); |
| 275 | } |
| 276 | |
| 277 | |
| 182 | 278 | static ADDRESS_MAP_START( casloopy_map, AS_PROGRAM, 32, casloopy_state ) |
| 183 | 279 | AM_RANGE(0x00000000, 0x00007fff) AM_RAM AM_SHARE("bios_rom") |
| 184 | 280 | AM_RANGE(0x01000000, 0x0107ffff) AM_RAM // stack pointer points here |
| 281 | AM_RANGE(0x04040000, 0x04043fff) AM_READWRITE8(casloopy_vram_r,casloopy_vram_w,0xffffffff) // tilemap + PCG |
| 282 | AM_RANGE(0x04051000, 0x040510ff) AM_READWRITE16(casloopy_pal_r,casloopy_pal_w,0xffffffff) |
| 283 | AM_RANGE(0x04058000, 0x04058007) AM_READWRITE16(casloopy_vregs_r,casloopy_vregs_w,0xffffffff) |
| 185 | 284 | // AM_RANGE(0x05ffff00, 0x05ffffff) - SH7021 internal i/o |
| 186 | 285 | AM_RANGE(0x06000000, 0x061fffff) AM_ROM AM_REGION("rom_cart",0) |
| 187 | 286 | AM_RANGE(0x07fff000, 0x07ffffff) AM_RAM |
| r21612 | r21613 | |
| 233 | 332 | /* video hardware */ |
| 234 | 333 | MCFG_SCREEN_ADD("screen", RASTER) |
| 235 | 334 | MCFG_SCREEN_REFRESH_RATE(60) |
| 236 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 335 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 237 | 336 | MCFG_SCREEN_SIZE(32*8, 32*8) |
| 238 | 337 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) |
| 239 | 338 | MCFG_SCREEN_UPDATE_DRIVER(casloopy_state, screen_update_casloopy) |