trunk/src/mess/drivers/casloopy.c
| r21614 | r21615 | |
| 163 | 163 | required_shared_ptr<UINT32> m_bios_rom; |
| 164 | 164 | UINT16 *m_paletteram; |
| 165 | 165 | UINT8 *m_vram; |
| 166 | UINT8 *m_bitmap_vram; |
| 167 | UINT16 sh7021_regs[0x100]; |
| 166 | 168 | int m_gfx_index; |
| 167 | 169 | DECLARE_DRIVER_INIT(casloopy); |
| 168 | 170 | virtual void machine_start(); |
| r21614 | r21615 | |
| 175 | 177 | DECLARE_WRITE16_MEMBER(casloopy_pal_w); |
| 176 | 178 | DECLARE_READ8_MEMBER(casloopy_vram_r); |
| 177 | 179 | DECLARE_WRITE8_MEMBER(casloopy_vram_w); |
| 180 | DECLARE_READ16_MEMBER(sh7021_r); |
| 181 | DECLARE_WRITE16_MEMBER(sh7021_w); |
| 182 | DECLARE_READ8_MEMBER(casloopy_bitmap_r); |
| 183 | DECLARE_WRITE8_MEMBER(casloopy_bitmap_w); |
| 178 | 184 | }; |
| 179 | 185 | |
| 180 | 186 | |
| 181 | 187 | static const gfx_layout casloopy_tile_layout = |
| 182 | 188 | { |
| 183 | 189 | 8,8, |
| 184 | | 0x400, |
| 190 | 0x10000/32, |
| 185 | 191 | 4, |
| 186 | 192 | { 0, 1, 2, 3 }, |
| 187 | 193 | { STEP8(0, 4) }, |
| r21614 | r21615 | |
| 192 | 198 | void casloopy_state::video_start() |
| 193 | 199 | { |
| 194 | 200 | /* TODO: proper sizes */ |
| 195 | | m_paletteram = auto_alloc_array(machine(), UINT16, 0x1000); |
| 196 | | m_vram = auto_alloc_array(machine(), UINT8, 0x4000); |
| 201 | m_paletteram = auto_alloc_array_clear(machine(), UINT16, 0x1000); |
| 202 | m_vram = auto_alloc_array_clear(machine(), UINT8, 0x10000); |
| 203 | m_bitmap_vram = auto_alloc_array_clear(machine(), UINT8, 0x20000); |
| 197 | 204 | |
| 198 | 205 | for (m_gfx_index = 0; m_gfx_index < MAX_GFX_ELEMENTS; m_gfx_index++) |
| 199 | 206 | if (machine().gfx[m_gfx_index] == 0) |
| r21614 | r21615 | |
| 217 | 224 | UINT16 tile = (m_vram[count+1])|(m_vram[count]<<8); |
| 218 | 225 | |
| 219 | 226 | tile &= 0x3ff; //??? |
| 220 | | tile |= 0x100; |
| 221 | 227 | |
| 222 | 228 | drawgfx_opaque(bitmap,cliprect,gfx,tile,7,0,0,x*8,y*8); |
| 223 | 229 | |
| r21614 | r21615 | |
| 225 | 231 | } |
| 226 | 232 | } |
| 227 | 233 | |
| 234 | static int test; |
| 235 | |
| 236 | if(machine().input().code_pressed(KEYCODE_Z)) |
| 237 | test+=0x100; |
| 238 | |
| 239 | if(machine().input().code_pressed(KEYCODE_X)) |
| 240 | test-=0x100; |
| 241 | |
| 242 | popmessage("%08x",test); |
| 243 | |
| 244 | count = test; |
| 245 | |
| 246 | for (y=cliprect.min_y;y<cliprect.max_y;y++) |
| 247 | { |
| 248 | for(x=0;x<256;x++) |
| 249 | { |
| 250 | UINT8 pix; |
| 251 | |
| 252 | pix = m_bitmap_vram[count]; |
| 253 | if(pix) |
| 254 | bitmap.pix16(y, x) = pix; |
| 255 | |
| 256 | count++; |
| 257 | } |
| 258 | } |
| 259 | |
| 228 | 260 | return 0; |
| 229 | 261 | } |
| 230 | 262 | |
| r21614 | r21615 | |
| 232 | 264 | { |
| 233 | 265 | if(offset == 4/2) |
| 234 | 266 | { |
| 235 | | return (machine().primary_screen->vblank() << 8); /*| (machine().primary_screen->vpos() & 0xff);*/ |
| 267 | return (machine().primary_screen->vblank() << 8) | (machine().rand() & 0xff); // vblank + vpos? |
| 236 | 268 | } |
| 237 | 269 | |
| 270 | if(offset == 2/2) |
| 271 | return machine().rand();/*(machine().primary_screen->hblank() << 8) | (machine().primary_screen->hpos() & 0xff);*/ // hblank + hpos? |
| 272 | |
| 238 | 273 | printf("%08x\n",offset*2); |
| 239 | 274 | |
| 240 | 275 | return 0xffff; |
| r21614 | r21615 | |
| 242 | 277 | |
| 243 | 278 | WRITE16_MEMBER(casloopy_state::casloopy_vregs_w) |
| 244 | 279 | { |
| 245 | | printf("%08x %08x\n",offset*2,data); |
| 280 | if(offset != 6/2) |
| 281 | printf("%08x %08x\n",offset*2,data); |
| 246 | 282 | } |
| 247 | 283 | |
| 248 | 284 | READ16_MEMBER(casloopy_state::casloopy_pal_r) |
| r21614 | r21615 | |
| 271 | 307 | { |
| 272 | 308 | m_vram[offset] = data; |
| 273 | 309 | |
| 274 | | machine().gfx[m_gfx_index]->mark_dirty(offset/256); |
| 310 | machine().gfx[m_gfx_index]->mark_dirty(offset/32); |
| 275 | 311 | } |
| 276 | 312 | |
| 313 | /* TODO: all of this should be internal to the SH core, this is just to check what it enables. */ |
| 314 | READ16_MEMBER(casloopy_state::sh7021_r) |
| 315 | { |
| 316 | return sh7021_regs[offset]; |
| 317 | } |
| 277 | 318 | |
| 319 | WRITE16_MEMBER(casloopy_state::sh7021_w) |
| 320 | { |
| 321 | COMBINE_DATA(&sh7021_regs[offset]); |
| 322 | |
| 323 | if(offset == 0x4e/2) |
| 324 | { |
| 325 | UINT32 src,dst,size,type; |
| 326 | |
| 327 | src = (sh7021_regs[0x40/2]<<16)|(sh7021_regs[0x42/2]&0xffff); |
| 328 | dst = (sh7021_regs[0x44/2]<<16)|(sh7021_regs[0x46/2]&0xffff); |
| 329 | size = (sh7021_regs[0x4a/2]&0xffff); |
| 330 | type = (sh7021_regs[0x4e/2]&0xffff); |
| 331 | |
| 332 | printf("%08x %08x %04x %04x\n",src & 0x7ffffff,dst & 0x7ffffff,size,type); |
| 333 | |
| 334 | sh7021_regs[0x4e/2]&=0xfffe; |
| 335 | } |
| 336 | |
| 337 | // printf("%08x %04x\n",sh7021_regs[offset],0x05ffff00+offset*2); |
| 338 | } |
| 339 | |
| 340 | READ8_MEMBER(casloopy_state::casloopy_bitmap_r) |
| 341 | { |
| 342 | return m_bitmap_vram[offset]; |
| 343 | } |
| 344 | |
| 345 | WRITE8_MEMBER(casloopy_state::casloopy_bitmap_w) |
| 346 | { |
| 347 | m_bitmap_vram[offset] = data; |
| 348 | } |
| 349 | |
| 278 | 350 | static ADDRESS_MAP_START( casloopy_map, AS_PROGRAM, 32, casloopy_state ) |
| 279 | 351 | AM_RANGE(0x00000000, 0x00007fff) AM_RAM AM_SHARE("bios_rom") |
| 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 |
| 352 | AM_RANGE(0x01000000, 0x0107ffff) AM_RAM AM_SHARE("wram")// stack pointer points here |
| 353 | AM_RANGE(0x04000000, 0x0401ffff) AM_READWRITE8(casloopy_bitmap_r,casloopy_bitmap_w,0xffffffff) |
| 354 | AM_RANGE(0x04040000, 0x0404ffff) AM_READWRITE8(casloopy_vram_r,casloopy_vram_w,0xffffffff) // tilemap + PCG |
| 282 | 355 | AM_RANGE(0x04051000, 0x040510ff) AM_READWRITE16(casloopy_pal_r,casloopy_pal_w,0xffffffff) |
| 283 | 356 | AM_RANGE(0x04058000, 0x04058007) AM_READWRITE16(casloopy_vregs_r,casloopy_vregs_w,0xffffffff) |
| 357 | AM_RANGE(0x0405b000, 0x0405b00f) AM_RAM // RGB brightness plus scrolling |
| 358 | AM_RANGE(0x05ffff00, 0x05ffffff) AM_READWRITE16(sh7021_r,sh7021_w,0xffffffff) |
| 284 | 359 | // AM_RANGE(0x05ffff00, 0x05ffffff) - SH7021 internal i/o |
| 285 | 360 | AM_RANGE(0x06000000, 0x061fffff) AM_ROM AM_REGION("rom_cart",0) |
| 286 | | AM_RANGE(0x07fff000, 0x07ffffff) AM_RAM |
| 361 | AM_RANGE(0x07000000, 0x070003ff) AM_RAM AM_SHARE("oram")// on-chip RAM, actually at 0xf000000 (1 kb) |
| 362 | AM_RANGE(0x09000000, 0x0907ffff) AM_RAM AM_SHARE("wram") |
| 287 | 363 | AM_RANGE(0x0e000000, 0x0e1fffff) AM_ROM AM_REGION("rom_cart",0) |
| 364 | AM_RANGE(0x0f000000, 0x0f0003ff) AM_RAM AM_SHARE("oram") |
| 288 | 365 | ADDRESS_MAP_END |
| 289 | 366 | |
| 290 | 367 | #if 0 |
| r21614 | r21615 | |
| 331 | 408 | |
| 332 | 409 | /* video hardware */ |
| 333 | 410 | MCFG_SCREEN_ADD("screen", RASTER) |
| 334 | | MCFG_SCREEN_REFRESH_RATE(60) |
| 335 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 336 | | MCFG_SCREEN_SIZE(32*8, 32*8) |
| 337 | | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) |
| 411 | MCFG_SCREEN_RAW_PARAMS(8000000, 444, 0, 256, 263, 0, 256) |
| 412 | |
| 413 | // MCFG_SCREEN_REFRESH_RATE(60) |
| 414 | // MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 415 | // MCFG_SCREEN_SIZE(444, 263) |
| 416 | // MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1) |
| 338 | 417 | MCFG_SCREEN_UPDATE_DRIVER(casloopy_state, screen_update_casloopy) |
| 339 | 418 | |
| 340 | 419 | MCFG_PALETTE_LENGTH(512) |