Previous 15994 Revisions Next

r8941 Sunday 29th August, 2010 at 20:14:24 UTC by Angelo Salese
[MZ-2500]: Added basic read modify write support and implemented 16-colors clut, most games are now better color-wise
[src/mess/drivers]mz2500.c

src/mess/drivers/mz2500.c
r8940r8941
1515    memory map:
1616    0x00000-0x3ffff Work RAM
1717    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)
1919    0x68000-0x6ffff IPL ROM (0x34-0x37)
2020    0x70000-0x71fff TVRAM (0x38)
2121    0x72000-0x73fff Kanji ROM / PCG RAM (banked) (0x39)
r8940r8941
4646static UINT8 key_mux;
4747static UINT8 cg_reg_index;
4848static UINT8 cg_reg[0x20];
49static UINT8 clut16[0x10];
4950
5051#define WRAM_RESET 0
5152#define IPL_RESET 1
r8940r8941
282283            pen_bit[0] = (vram[count+0x0000 + plane*0x2000]>>(xi)) & 1 ? 1 : 0; //B
283284            pen_bit[1] = (vram[count+0x4000 + plane*0x2000]>>(xi)) & 1 ? 2 : 0; //R
284285            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
286287
287288            pen = 0;
288289            for(pen_i=0;pen_i<4;pen_i++)
289290               pen |= pen_bit[pen_i];
290291
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];
293294         }
294295         count++;
295296      }
r8940r8941
335336
336337static VIDEO_UPDATE( mz2500 )
337338{
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?
339340
340341   if(pal_select)
341342      draw_tv_screen(screen->machine,bitmap,cliprect);
r8940r8941
401402   UINT8 *ram = memory_region(machine, "maincpu");
402403   UINT8 cur_bank = bank_val[bank_num];
403404
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
404408   switch(cur_bank)
405409   {
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      }
406471      case 0x34:
407472      case 0x35:
408473      case 0x36:
r8940r8941
539604      case 0: text_reg_index = data; break;
540605      case 1:
541606         text_reg[text_reg_index] = data;
607         printf("[%02x] %02x\n",text_reg_index,data);
608
542609         if(text_reg_index == 0x0a) // set 256 color palette
543610         {
544611            int i,r,g,b;
r8940r8941
567634
568635               palette_set_color_rgb(space->machine, i+0x100,pal3bit(r),pal3bit(g),pal3bit(b));
569636            }
637
570638         }
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         }
571647         //printf("[%02x]<- %02x\n",text_reg[text_reg_index],text_reg_index);
572648         break;
573649      case 2: /* CG MASK reg */ break;
r8940r8941
770846   if((cg_reg_index & 0x1f) == 0x0a) //accessing VE LO reg clears VE HI reg
771847      cg_reg[0x0b] = 0;
772848
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
774850   {
775851      UINT32 i;
776852      UINT8 *vram = memory_region(space->machine, "maincpu");

Previous 15994 Revisions Next


© 1998-2018 The MESS Team