src/mess/drivers/mz2500.c
| r8940 | r8941 | |
| 15 | 15 | memory map: |
| 16 | 16 | 0x00000-0x3ffff Work RAM |
| 17 | 17 | 0x40000-0x5ffff CG RAM (address bitswapped?) |
| 18 | | 0x60000-0x67fff "Read modify write" area (related to the CG RAM) |
| 18 | 0x60000-0x67fff "Read modify write" area (related to the CG RAM) (0x30-0x33) |
| 19 | 19 | 0x68000-0x6ffff IPL ROM (0x34-0x37) |
| 20 | 20 | 0x70000-0x71fff TVRAM (0x38) |
| 21 | 21 | 0x72000-0x73fff Kanji ROM / PCG RAM (banked) (0x39) |
| r8940 | r8941 | |
| 46 | 46 | static UINT8 key_mux; |
| 47 | 47 | static UINT8 cg_reg_index; |
| 48 | 48 | static UINT8 cg_reg[0x20]; |
| 49 | static UINT8 clut16[0x10]; |
| 49 | 50 | |
| 50 | 51 | #define WRAM_RESET 0 |
| 51 | 52 | #define IPL_RESET 1 |
| r8940 | r8941 | |
| 282 | 283 | pen_bit[0] = (vram[count+0x0000 + plane*0x2000]>>(xi)) & 1 ? 1 : 0; //B |
| 283 | 284 | pen_bit[1] = (vram[count+0x4000 + plane*0x2000]>>(xi)) & 1 ? 2 : 0; //R |
| 284 | 285 | pen_bit[2] = (vram[count+0x8000 + plane*0x2000]>>(xi)) & 1 ? 4 : 0; //G |
| 285 | | pen_bit[3] = (vram[count+0xc000 + plane*0x2000]>>(xi)) & 1 ? 0 : 8; //I FIXME: this should be swapped |
| 286 | pen_bit[3] = (vram[count+0xc000 + plane*0x2000]>>(xi)) & 1 ? 8 : 0; //I |
| 286 | 287 | |
| 287 | 288 | pen = 0; |
| 288 | 289 | for(pen_i=0;pen_i<4;pen_i++) |
| 289 | 290 | pen |= pen_bit[pen_i]; |
| 290 | 291 | |
| 291 | | if(pen != 8) |
| 292 | | *BITMAP_ADDR16(bitmap, y, x+xi) = machine->pens[pen+0x200]; |
| 292 | if(pen != 0 || clut16[pen] & 0x10) |
| 293 | *BITMAP_ADDR16(bitmap, y, x+xi) = machine->pens[(clut16[pen] & 0x0f)+0x200]; |
| 293 | 294 | } |
| 294 | 295 | count++; |
| 295 | 296 | } |
| r8940 | r8941 | |
| 335 | 336 | |
| 336 | 337 | static VIDEO_UPDATE( mz2500 ) |
| 337 | 338 | { |
| 338 | | bitmap_fill(bitmap, cliprect, MAKE_ARGB(0xff,0x00,0x00,0x00)); |
| 339 | bitmap_fill(bitmap, cliprect, screen->machine->pens[(clut16[0] & 0xf)+0x200]); //TODO: correct? |
| 339 | 340 | |
| 340 | 341 | if(pal_select) |
| 341 | 342 | draw_tv_screen(screen->machine,bitmap,cliprect); |
| r8940 | r8941 | |
| 401 | 402 | UINT8 *ram = memory_region(machine, "maincpu"); |
| 402 | 403 | UINT8 cur_bank = bank_val[bank_num]; |
| 403 | 404 | |
| 405 | // if(cur_bank >= 0x30 && cur_bank <= 0x33) |
| 406 | // printf("CG REG = %02x %02x %02x %02x | offset = %04x | data = %02x\n",cg_reg[0],cg_reg[1],cg_reg[2],cg_reg[3],offset,data); |
| 407 | |
| 404 | 408 | switch(cur_bank) |
| 405 | 409 | { |
| 410 | case 0x30: |
| 411 | case 0x31: |
| 412 | case 0x32: |
| 413 | case 0x33: |
| 414 | { |
| 415 | // READ MODIFY WRITE |
| 416 | if(cg_reg[0x0e] == 0x3) |
| 417 | { |
| 418 | // ... |
| 419 | } |
| 420 | else |
| 421 | { |
| 422 | if((cg_reg[0x05] & 0xc0) == 0x00) //replace |
| 423 | { |
| 424 | if(cg_reg[5] & 1) //B |
| 425 | { |
| 426 | ram[offset+((cur_bank & 3)*0x2000)+0x40000] &= ~cg_reg[6]; |
| 427 | ram[offset+((cur_bank & 3)*0x2000)+0x40000] |= (cg_reg[4] & 1) ? (data & cg_reg[0] & cg_reg[6]) : 0; |
| 428 | } |
| 429 | if(cg_reg[5] & 2) //R |
| 430 | { |
| 431 | ram[offset+((cur_bank & 3)*0x2000)+0x44000] &= ~cg_reg[6]; |
| 432 | ram[offset+((cur_bank & 3)*0x2000)+0x44000] |= (cg_reg[4] & 2) ? (data & cg_reg[1] & cg_reg[6]) : 0; |
| 433 | } |
| 434 | if(cg_reg[5] & 4) //G |
| 435 | { |
| 436 | ram[offset+((cur_bank & 3)*0x2000)+0x48000] &= ~cg_reg[6]; |
| 437 | ram[offset+((cur_bank & 3)*0x2000)+0x48000] |= (cg_reg[4] & 4) ? (data & cg_reg[2] & cg_reg[6]) : 0; |
| 438 | } |
| 439 | if(cg_reg[5] & 8) //I |
| 440 | { |
| 441 | ram[offset+((cur_bank & 3)*0x2000)+0x4c000] &= ~cg_reg[6]; |
| 442 | ram[offset+((cur_bank & 3)*0x2000)+0x4c000] |= (cg_reg[4] & 8) ? (data & cg_reg[3] & cg_reg[6]) : 0; |
| 443 | } |
| 444 | } |
| 445 | else if((cg_reg[0x05] & 0xc0) == 0x40) //pset |
| 446 | { |
| 447 | if(cg_reg[5] & 1) //B |
| 448 | { |
| 449 | ram[offset+((cur_bank & 3)*0x2000)+0x40000] &= ~data; |
| 450 | ram[offset+((cur_bank & 3)*0x2000)+0x40000] |= (cg_reg[4] & 1) ? (data & cg_reg[0]) : 0; |
| 451 | } |
| 452 | if(cg_reg[5] & 2) //R |
| 453 | { |
| 454 | ram[offset+((cur_bank & 3)*0x2000)+0x44000] &= ~data; |
| 455 | ram[offset+((cur_bank & 3)*0x2000)+0x44000] |= (cg_reg[4] & 2) ? (data & cg_reg[1]) : 0; |
| 456 | } |
| 457 | if(cg_reg[5] & 4) //G |
| 458 | { |
| 459 | ram[offset+((cur_bank & 3)*0x2000)+0x48000] &= ~data; |
| 460 | ram[offset+((cur_bank & 3)*0x2000)+0x48000] |= (cg_reg[4] & 4) ? (data & cg_reg[2]) : 0; |
| 461 | } |
| 462 | if(cg_reg[5] & 8) //I |
| 463 | { |
| 464 | ram[offset+((cur_bank & 3)*0x2000)+0x4c000] &= ~data; |
| 465 | ram[offset+((cur_bank & 3)*0x2000)+0x4c000] |= (cg_reg[4] & 8) ? (data & cg_reg[3]) : 0; |
| 466 | } |
| 467 | } |
| 468 | } |
| 469 | break; |
| 470 | } |
| 406 | 471 | case 0x34: |
| 407 | 472 | case 0x35: |
| 408 | 473 | case 0x36: |
| r8940 | r8941 | |
| 539 | 604 | case 0: text_reg_index = data; break; |
| 540 | 605 | case 1: |
| 541 | 606 | text_reg[text_reg_index] = data; |
| 607 | printf("[%02x] %02x\n",text_reg_index,data); |
| 608 | |
| 542 | 609 | if(text_reg_index == 0x0a) // set 256 color palette |
| 543 | 610 | { |
| 544 | 611 | int i,r,g,b; |
| r8940 | r8941 | |
| 567 | 634 | |
| 568 | 635 | palette_set_color_rgb(space->machine, i+0x100,pal3bit(r),pal3bit(g),pal3bit(b)); |
| 569 | 636 | } |
| 637 | |
| 570 | 638 | } |
| 639 | if(text_reg_index >= 0x80 && text_reg_index <= 0x8f) //Bitmap 16 clut registers |
| 640 | { |
| 641 | /* |
| 642 | ---x ---- priority |
| 643 | ---- xxxx clut number |
| 644 | */ |
| 645 | clut16[text_reg_index & 0xf] = data & 0x1f; |
| 646 | } |
| 571 | 647 | //printf("[%02x]<- %02x\n",text_reg[text_reg_index],text_reg_index); |
| 572 | 648 | break; |
| 573 | 649 | case 2: /* CG MASK reg */ break; |
| r8940 | r8941 | |
| 770 | 846 | if((cg_reg_index & 0x1f) == 0x0a) //accessing VE LO reg clears VE HI reg |
| 771 | 847 | cg_reg[0x0b] = 0; |
| 772 | 848 | |
| 773 | | if((cg_reg_index & 0x1f) == 0x05) //clear bitmap buffer |
| 849 | if((cg_reg_index & 0x1f) == 0x05 && (cg_reg[0x05] & 0xc0) == 0x80) //clear bitmap buffer |
| 774 | 850 | { |
| 775 | 851 | UINT32 i; |
| 776 | 852 | UINT8 *vram = memory_region(space->machine, "maincpu"); |