trunk/src/mame/drivers/gunpey.c
| r21520 | r21521 | |
| 217 | 217 | TIMER_DEVICE_CALLBACK_MEMBER(gunpey_scanline); |
| 218 | 218 | TIMER_CALLBACK_MEMBER(blitter_end); |
| 219 | 219 | void gunpey_irq_check(UINT8 irq_type); |
| 220 | | void flush_pal_data(int x, int y); |
| 220 | UINT8 draw_gfx(bitmap_ind16 &bitmap,const rectangle &cliprect,int count); |
| 221 | 221 | UINT16 m_vram_bank; |
| 222 | 222 | |
| 223 | |
| 223 | 224 | //UINT16 main_vram[0x800][0x800]; |
| 224 | 225 | }; |
| 225 | 226 | |
| r21520 | r21521 | |
| 229 | 230 | m_blit_buffer = auto_alloc_array(machine(), UINT16, 512*512); |
| 230 | 231 | } |
| 231 | 232 | |
| 232 | | UINT32 gunpey_state::screen_update_gunpey(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 233 | UINT8 gunpey_state::draw_gfx(bitmap_ind16 &bitmap,const rectangle &cliprect,int count) |
| 233 | 234 | { |
| 234 | | //UINT16 *blit_buffer = m_blit_buffer; |
| 235 | 235 | int x,y; |
| 236 | | int count; |
| 237 | 236 | int bpp_sel; |
| 238 | 237 | int height; |
| 239 | 238 | int width; |
| 240 | 239 | int color; |
| 241 | | UINT16 vram_bank = m_vram_bank & 0x7fff; |
| 242 | 240 | UINT8 *vram = memregion("vram")->base(); |
| 243 | 241 | |
| 244 | | bitmap.fill(machine().pens[0], cliprect); //black pen |
| 245 | | |
| 246 | | vram_bank ^= 0x2000; |
| 247 | | |
| 248 | | /* last 4 entries are special, skip them for now. */ |
| 249 | | for(count = vram_bank/2;count<(vram_bank+0x2000-0x40)/2;count+=0x10/2) |
| 242 | if(!(m_wram[count+0] & 1)) |
| 250 | 243 | { |
| 251 | | if(!(m_wram[count+0] & 1)) |
| 252 | | { |
| 253 | | x = (m_wram[count+3] >> 8) | ((m_wram[count+4] & 0x03) << 8); |
| 254 | | y = (m_wram[count+4] >> 8) | ((m_wram[count+4] & 0x30) << 4); |
| 255 | | height = (m_wram[count+5] >> 8); |
| 256 | | width = (m_wram[count+5] & 0xff); |
| 257 | | bpp_sel = (m_wram[count+0] & 0x18); |
| 258 | | color = (m_wram[count+0] >> 8); |
| 244 | x = (m_wram[count+3] >> 8) | ((m_wram[count+4] & 0x03) << 8); |
| 245 | y = (m_wram[count+4] >> 8) | ((m_wram[count+4] & 0x30) << 4); |
| 246 | height = (m_wram[count+5] >> 8); |
| 247 | width = (m_wram[count+5] & 0xff); |
| 248 | bpp_sel = (m_wram[count+0] & 0x18); |
| 249 | color = (m_wram[count+0] >> 8); |
| 259 | 250 | |
| 260 | | x-=0x160; |
| 261 | | y-=0x188; |
| 251 | x-=0x160; |
| 252 | y-=0x188; |
| 262 | 253 | |
| 263 | | //UINT32 col = 0xffffff; |
| 264 | | |
| 254 | //UINT32 col = 0xffffff; |
| 265 | 255 | // UINT32 val = (m_wram[count+1] << 16) | ((m_wram[count+2])); |
| 266 | | |
| 267 | | int xsource = ((m_wram[count+2] & 0x00ff) << 4) | ((m_wram[count+1] & 0xf000) >> 12); |
| 268 | | int ysource = ((m_wram[count+2] & 0xf000) >> 12)| ((m_wram[count+3] & 0x00ff) << 4); |
| 269 | | |
| 270 | | //printf("%08x %04x %04x\n", val, m_wram[count+1],m_wram[count+2] ); |
| 271 | | |
| 256 | int xsource = ((m_wram[count+2] & 0x00ff) << 4) | ((m_wram[count+1] & 0xf000) >> 12); |
| 257 | int ysource = ((m_wram[count+2] & 0xf000) >> 12)| ((m_wram[count+3] & 0x00ff) << 4); |
| 258 | //printf("%08x %04x %04x\n", val, m_wram[count+1],m_wram[count+2] ); |
| 272 | 259 | // UINT16 xsource = (m_wram[count+2] & 0x00ff << 4) | (m_wram[count+1] & 0xf000 >> 12); |
| 273 | | // UINT16 ysource = (m_wram[count+2] & 0xff00 >>8) | (m_wram[count+3] & 0x000f <<8); |
| 260 | //xsource<<=1; |
| 274 | 261 | |
| 275 | | //xsource<<=1; |
| 262 | xsource<<=1; |
| 263 | ysource <<=2; |
| 276 | 264 | |
| 277 | | |
| 278 | | xsource<<=1; |
| 279 | | ysource <<=2; |
| 280 | | |
| 281 | | |
| 282 | | |
| 283 | | if(bpp_sel == 0x00) // 4bpp |
| 265 | if(bpp_sel == 0x00) // 4bpp |
| 266 | { |
| 267 | for(int yi=0;yi<height;yi++) |
| 284 | 268 | { |
| 285 | | for(int yi=0;yi<height;yi++) |
| 269 | for(int xi=0;xi<width/2;xi++) |
| 286 | 270 | { |
| 287 | | for(int xi=0;xi<width/2;xi++) |
| 288 | | { |
| 289 | | UINT8 data = vram[((((ysource+yi)&0x7ff)*0x800) + ((xsource+xi)&0x7ff))]; |
| 290 | | UINT8 pix; |
| 291 | | UINT32 col_offs; |
| 292 | | UINT16 color_data; |
| 271 | UINT8 data = vram[((((ysource+yi)&0x7ff)*0x800) + ((xsource+xi)&0x7ff))]; |
| 272 | UINT8 pix; |
| 273 | UINT32 col_offs; |
| 274 | UINT16 color_data; |
| 293 | 275 | |
| 294 | | pix = (data & 0x0f); |
| 295 | | col_offs = ((pix + color*0x10) & 0xff) << 1; |
| 296 | | col_offs+= ((pix + color*0x10) >> 8)*0x800; |
| 297 | | color_data = (vram[col_offs])|(vram[col_offs+1]<<8); |
| 276 | pix = (data & 0x0f); |
| 277 | col_offs = ((pix + color*0x10) & 0xff) << 1; |
| 278 | col_offs+= ((pix + color*0x10) >> 8)*0x800; |
| 279 | color_data = (vram[col_offs])|(vram[col_offs+1]<<8); |
| 298 | 280 | |
| 299 | | if(!(color_data & 0x8000)) |
| 300 | | if(cliprect.contains(x+(xi*2), y+yi)) |
| 301 | | bitmap.pix16(y+yi, x+(xi*2)) = color_data & 0x7fff; |
| 281 | if(!(color_data & 0x8000)) |
| 282 | if(cliprect.contains(x+(xi*2), y+yi)) |
| 283 | bitmap.pix16(y+yi, x+(xi*2)) = color_data & 0x7fff; |
| 302 | 284 | |
| 303 | | pix = (data & 0xf0)>>4; |
| 304 | | col_offs = ((pix + color*0x10) & 0xff) << 1; |
| 305 | | col_offs+= ((pix + color*0x10) >> 8)*0x800; |
| 306 | | color_data = (vram[col_offs])|(vram[col_offs+1]<<8); |
| 285 | pix = (data & 0xf0)>>4; |
| 286 | col_offs = ((pix + color*0x10) & 0xff) << 1; |
| 287 | col_offs+= ((pix + color*0x10) >> 8)*0x800; |
| 288 | color_data = (vram[col_offs])|(vram[col_offs+1]<<8); |
| 307 | 289 | |
| 308 | | if(!(color_data & 0x8000)) |
| 290 | if(!(color_data & 0x8000)) |
| 309 | 291 | if(cliprect.contains(x+1+(xi*2), y+yi)) |
| 310 | 292 | bitmap.pix16(y+yi, x+1+(xi*2)) = color_data & 0x7fff; |
| 311 | | } |
| 312 | 293 | } |
| 313 | 294 | } |
| 314 | | else if(bpp_sel == 0x08) // 6bpp |
| 295 | } |
| 296 | else if(bpp_sel == 0x08) // 6bpp |
| 297 | { |
| 298 | #if 0 |
| 299 | for(int yi=0;yi<height;yi++) |
| 315 | 300 | { |
| 316 | | #if 0 |
| 317 | | for(int yi=0;yi<height;yi++) |
| 301 | for(int xi=0;xi<width;xi++) |
| 318 | 302 | { |
| 319 | | for(int xi=0;xi<width;xi++) |
| 320 | | { |
| 321 | | UINT8 data = vram[((((ysource+yi)&0x7ff)*0x800) + ((xsource+xi)&0x7ff))]; |
| 322 | | UINT8 pix; |
| 323 | | UINT32 col_offs; |
| 324 | | UINT16 color_data; |
| 303 | UINT8 data = vram[((((ysource+yi)&0x7ff)*0x800) + ((xsource+xi)&0x7ff))]; |
| 304 | UINT8 pix; |
| 305 | UINT32 col_offs; |
| 306 | UINT16 color_data; |
| 325 | 307 | |
| 326 | | pix = (data & 0x3f); |
| 327 | | |
| 328 | | if(cliprect.contains(x+xi, y+yi)) |
| 329 | | bitmap.pix16(y+yi, x+xi) = pix + color*64; |
| 330 | | } |
| 308 | pix = (data & 0x3f); |
| 309 | if(cliprect.contains(x+xi, y+yi)) |
| 310 | bitmap.pix16(y+yi, x+xi) = pix + color*64; |
| 331 | 311 | } |
| 332 | | #endif |
| 333 | 312 | } |
| 334 | | else if(bpp_sel == 0x10) // 8bpp |
| 313 | #endif |
| 314 | } |
| 315 | else if(bpp_sel == 0x10) // 8bpp |
| 316 | { |
| 317 | for(int yi=0;yi<height;yi++) |
| 335 | 318 | { |
| 336 | | for(int yi=0;yi<height;yi++) |
| 319 | for(int xi=0;xi<width;xi++) |
| 337 | 320 | { |
| 338 | | for(int xi=0;xi<width;xi++) |
| 339 | | { |
| 340 | | UINT8 data = vram[((((ysource+yi)&0x7ff)*0x800) + ((xsource+xi)&0x7ff))]; |
| 341 | | UINT8 pix; |
| 342 | | UINT32 col_offs; |
| 343 | | UINT16 color_data; |
| 321 | UINT8 data = vram[((((ysource+yi)&0x7ff)*0x800) + ((xsource+xi)&0x7ff))]; |
| 322 | UINT8 pix; |
| 323 | UINT32 col_offs; |
| 324 | UINT16 color_data; |
| 344 | 325 | |
| 345 | | pix = (data & 0xff); |
| 346 | | col_offs = ((pix + color*0x100) & 0xff) << 1; |
| 347 | | col_offs+= ((pix + color*0x100) >> 8)*0x800; |
| 348 | | color_data = (vram[col_offs])|(vram[col_offs+1]<<8); |
| 326 | pix = (data & 0xff); |
| 327 | col_offs = ((pix + color*0x100) & 0xff) << 1; |
| 328 | col_offs+= ((pix + color*0x100) >> 8)*0x800; |
| 329 | color_data = (vram[col_offs])|(vram[col_offs+1]<<8); |
| 349 | 330 | |
| 350 | | if(!(color_data & 0x8000)) |
| 351 | | if(cliprect.contains(x+xi, y+yi)) |
| 352 | | bitmap.pix16(y+yi, x+xi) = color_data & 0x7fff; |
| 353 | | } |
| 331 | if(!(color_data & 0x8000)) |
| 332 | if(cliprect.contains(x+xi, y+yi)) |
| 333 | bitmap.pix16(y+yi, x+xi) = color_data & 0x7fff; |
| 354 | 334 | } |
| 355 | 335 | } |
| 356 | | else if(bpp_sel == 0x18) // RGB32k |
| 357 | | { |
| 358 | | // ... |
| 359 | | } |
| 360 | 336 | } |
| 337 | else if(bpp_sel == 0x18) // RGB32k |
| 338 | { |
| 339 | // ... |
| 340 | } |
| 361 | 341 | } |
| 362 | 342 | |
| 343 | return m_wram[count+0] & 0x80; |
| 344 | } |
| 363 | 345 | |
| 346 | UINT32 gunpey_state::screen_update_gunpey(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 347 | { |
| 348 | //UINT16 *blit_buffer = m_blit_buffer; |
| 349 | int count; |
| 350 | UINT16 vram_bank = m_vram_bank & 0x7fff; |
| 351 | UINT8 end_mark; |
| 352 | |
| 353 | bitmap.fill(machine().pens[0], cliprect); //black pen |
| 354 | |
| 355 | vram_bank ^= 0x2000; |
| 356 | |
| 357 | /* last 4 entries are special, skip them for now. */ |
| 358 | for(count = vram_bank/2;count<(vram_bank+0x1000)/2;count+=0x10/2) |
| 359 | { |
| 360 | end_mark = draw_gfx(bitmap,cliprect,count); |
| 361 | |
| 362 | if(end_mark == 0x80) |
| 363 | break; |
| 364 | } |
| 365 | |
| 366 | for(count = (vram_bank+0x1000)/2;count<(vram_bank+0x2000)/2;count+=0x10/2) |
| 367 | { |
| 368 | end_mark = draw_gfx(bitmap,cliprect,count); |
| 369 | |
| 370 | if(end_mark == 0x80) |
| 371 | break; |
| 372 | } |
| 373 | |
| 364 | 374 | return 0; |
| 365 | 375 | } |
| 366 | 376 | |
| r21520 | r21521 | |
| 416 | 426 | gunpey_irq_check(4); |
| 417 | 427 | } |
| 418 | 428 | |
| 419 | | //flush_pal_data((dstx+x) & 0x7fe,(dsty+y) & 0x7ff); |
| 420 | 429 | |
| 421 | | void gunpey_state::flush_pal_data(int x, int y) |
| 422 | | { |
| 423 | | if(y < 512 && x < 512) |
| 424 | | { |
| 425 | | UINT8 *vram = memregion("vram")->base(); |
| 426 | | int val = (vram[y*0x800+x]) | (vram[y*0x800+x+1]<<8); |
| 427 | | int r,g,b; |
| 428 | 430 | |
| 429 | | b = (val & 0x001f) >> 0; |
| 430 | | g = (val & 0x03e0) >> 5; |
| 431 | | r = (val & 0x7c00) >> 10; |
| 432 | | |
| 433 | | palette_set_color(machine(), y*256+x/2, MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b))); |
| 434 | | } |
| 435 | | } |
| 436 | | |
| 437 | 431 | WRITE8_MEMBER(gunpey_state::gunpey_blitter_w) |
| 438 | 432 | { |
| 439 | 433 | // UINT16 *blit_buffer = m_blit_buffer; |
| r21520 | r21521 | |
| 485 | 479 | for (int x=0;x<xsize;x++) |
| 486 | 480 | { |
| 487 | 481 | vram[(((dsty+y)&0x7ff)*0x800)+((dstx+x)&0x7ff)] = blit_rom[(((srcy+y)&0x7ff)*0x800)+((srcx+x)&0x7ff)]; |
| 488 | | //flush_pal_data((dstx+x) & 0x7fe,(dsty+y) & 0x7ff); |
| 489 | 482 | } |
| 490 | 483 | } |
| 491 | 484 | |