Previous 15994 Revisions Next

r8958 Monday 30th August, 2010 at 14:09:43 UTC by Angelo Salese
[MZ-2500]: Fixed PCG catching and added TVRAM scrolling, fixes Xevious graphics
[src/mess/drivers]mz2500.c

src/mess/drivers/mz2500.c
r8957r8958
7676[2] xx-- ---- kanji select
7777*/
7878
79static void draw_80x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
79static void draw_80x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 map_addr)
8080{
8181   UINT8 *vram = memory_region(machine, "maincpu");
8282   int x,y,count,xi,yi;
8383   UINT8 *gfx_data;
8484   UINT8 y_step;
85   UINT8 s_y;
8586
86   count = 0x70000;
87   count = (map_addr & 0x7ff);
8788
8889   y_step = (text_font_reg) ? 1 : 2;
90   s_y = text_reg[9] & 0xf;
8991
90   for (y=0;y<25;y+=y_step)
92   for (y=0;y<26;y+=y_step)
9193   {
9294      for (x=0;x<80;x++)
9395      {
94         int tile = vram[count+0x0000] & 0xff;
95         int attr = vram[count+0x0800];
96         int tile_bank = vram[count+0x1000] & 0x3f;
97         int gfx_sel = (attr & 0x38) | (vram[count+0x1000] & 0xc0);
98         //int gfx_num;
96         int tile = vram[0x70000+count+0x0000] & 0xff;
97         int attr = vram[0x70000+count+0x0800];
98         int tile_bank = vram[0x70000+count+0x1000] & 0x3f;
99         int gfx_sel = (attr & 0x38) | (vram[0x70000+count+0x1000] & 0xc0);
99100         int color = attr & 7;
100101
102         if(gfx_sel & 8) // Xevious, PCG 8 colors have priority above kanji roms
103            gfx_data = memory_region(machine,"pcg");
101104         if(gfx_sel == 0x80)
102105         {
103106            gfx_data = memory_region(machine,"kanji");
r8957r8958
138141               }
139142
140143               if(pen)
141                  *BITMAP_ADDR16(bitmap, (y*8+yi), x*8+xi) = machine->pens[pen];
144               {
145                  if((y*8+yi-s_y) >= 0 && (y*8+yi-s_y) < 200)
146                     *BITMAP_ADDR16(bitmap, (y*8+yi-s_y), x*8+xi) = machine->pens[pen];
147               }
142148            }
143149         }
144150            //drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[gfx_num],tile,color,0,0,x*8,(y)*8);
145151
146152         count++;
153         count&=0x7ff;
147154      }
148155   }
149156}
150157
151static void draw_40x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int plane)
158static void draw_40x25(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int plane,UINT16 map_addr)
152159{
153160   UINT8 *vram = memory_region(machine, "maincpu");
154161   int x,y,count,xi,yi;
155162   UINT8 *gfx_data;
156163   UINT8 y_step;
164   UINT8 s_y;
157165
158   count = 0x70000 + (plane * 0x400);
166   count = (((plane * 0x400) + map_addr) & 0x7ff);
159167
160168   y_step = (text_font_reg) ? 1 : 2;
169   s_y = text_reg[9] & 0xf;
161170
162   for (y=0;y<25;y+=y_step)
171   for (y=0;y<26;y+=y_step)
163172   {
164173      for (x=0;x<40;x++)
165174      {
166         int tile = vram[count+0x0000] & 0xff;
167         int attr = vram[count+0x0800];
168         int tile_bank = vram[count+0x1000] & 0x3f;
169         int gfx_sel = (attr & 0x38) | (vram[count+0x1000] & 0xc0);
175         int tile = vram[0x70000+count+0x0000] & 0xff;
176         int attr = vram[0x70000+count+0x0800];
177         int tile_bank = vram[0x70000+count+0x1000] & 0x3f;
178         int gfx_sel = (attr & 0x38) | (vram[0x70000+count+0x1000] & 0xc0);
170179         //int gfx_num;
171180         int color = attr & 7;
172181
173         if(gfx_sel == 0x80 || gfx_sel == 0xc0)
174            gfx_data = memory_region(machine,"kanji"); //TODO
182         if(gfx_sel & 8) // Xevious, PCG 8 colors have priority above kanji roms
183            gfx_data = memory_region(machine,"pcg");
184         else if(gfx_sel == 0x80)
185         {
186            gfx_data = memory_region(machine,"kanji");
187            tile|= tile_bank << 8;
188            if(y_step == 2)
189               tile &= 0x3ffe;
190         }
191         else if(gfx_sel == 0xc0)
192         {
193            gfx_data = memory_region(machine,"kanji");
194            tile|= (tile_bank << 8);
195            if(y_step == 2)
196               tile &= 0x3ffe;
197            tile|=0x4000;
198         }
175199         else
200         {
176201            gfx_data = memory_region(machine,"pcg");
202         }
177203
178         tile|= tile_bank << 8;
179
180204         for(yi=0;yi<8*y_step;yi++)
181205         {
182206            for(xi=0;xi<8;xi++)
r8957r8958
195219                  pen = ((gfx_data[tile*8+yi+((gfx_sel & 0x30)<<7)]>>(7-xi)) & 1) ? color : 0;
196220
197221               if(pen)
198                  *BITMAP_ADDR16(bitmap, (y*8+yi), x*8+xi) = machine->pens[pen];
222               {
223                  if((y*8+yi-s_y) >= 0 && (y*8+yi-s_y) < 200)
224                     *BITMAP_ADDR16(bitmap, (y*8+yi-s_y), x*8+xi) = machine->pens[pen];
225               }
199226            }
200227         }
201228            //drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[gfx_num],tile,color,0,0,x*8,(y)*8);
202229
203230         count++;
231         count&=0x7ff;
204232      }
205233   }
206234}
207235
208236static void draw_tv_screen(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
209237{
210   //w = (text_col_size) ? 2 : 1; //80 : 40
238   UINT16 base_addr;
239
240   base_addr = text_reg[1] | ((text_reg[2] & 0x7) << 8);
241
242//   popmessage("%02x",text_reg[9]);
243
211244   if(text_col_size)
212      draw_80x25(machine,bitmap,cliprect);
245      draw_80x25(machine,bitmap,cliprect,base_addr);
213246   else
214247   {
215248      int tv_mode;
r8957r8958
220253      {
221254//         case 0: mixed 6bpp mode
222255         case 1:
223            draw_40x25(machine,bitmap,cliprect,0);
256            draw_40x25(machine,bitmap,cliprect,0,base_addr);
224257            break;
225258         case 2:
226            draw_40x25(machine,bitmap,cliprect,1);
259            draw_40x25(machine,bitmap,cliprect,1,base_addr);
227260            break;
228261         case 3:
229            draw_40x25(machine,bitmap,cliprect,0);
230            draw_40x25(machine,bitmap,cliprect,1);
262            draw_40x25(machine,bitmap,cliprect,0,base_addr);
263            draw_40x25(machine,bitmap,cliprect,1,base_addr);
231264            break;
232265         default: popmessage("%02x %02x %02x",tv_mode & 3,text_reg[1],text_reg[2]); break;
233266      }
r8957r8958
242275   int x,y,xi,pen_i;
243276   UINT32 wa_reg;
244277   UINT8 s_x;
278   UINT8 base_mask;
245279
246   count = (cg_reg[0x10]) | ((cg_reg[0x11] & 0x3f) << 8);
247   wa_reg = (cg_reg[0x12]) | ((cg_reg[0x13] & 0x3f) << 8);
280   base_mask = (x_size == 640) ? 0x3f : 0x1f;
281
282   count = (cg_reg[0x10]) | ((cg_reg[0x11] & base_mask) << 8);
283   wa_reg = (cg_reg[0x12]) | ((cg_reg[0x13] & base_mask) << 8);
248284   /* TODO: layer 2 scrolling */
249285   s_x = (cg_reg[0x0f] & 0xf);
250286
r8957r8958
267303               *BITMAP_ADDR16(bitmap, y, x+xi+s_x) = machine->pens[(clut16[pen] & 0x0f)+0x200];
268304         }
269305         count++;
270         count&=0x3fff;
306         count&=((base_mask<<8) | 0xff);
271307         if(count > wa_reg)
272308            count = 0;
273309      }
r8957r8958
341377      draw_tv_screen(screen->machine,bitmap,cliprect);
342378      draw_cg_screen(screen->machine,bitmap,cliprect);
343379      //draw_tv_screen(screen->machine,bitmap,cliprect);
344      popmessage("%02x (%02x %02x) (%02x %02x) (%02x %02x) (%02x %02x)",cg_reg[0x0f],cg_reg[0x10],cg_reg[0x11],cg_reg[0x12],cg_reg[0x13],cg_reg[0x14],cg_reg[0x15],cg_reg[0x16],cg_reg[0x17]);
380   //   popmessage("%02x (%02x %02x) (%02x %02x) (%02x %02x) (%02x %02x)",cg_reg[0x0f],cg_reg[0x10],cg_reg[0x11],cg_reg[0x12],cg_reg[0x13],cg_reg[0x14],cg_reg[0x15],cg_reg[0x16],cg_reg[0x17]);
345381   }
346382   else //4096 mode colors
347383   {
r8957r8958
460496         //printf("%04x %02x\n",offset+bank_num*0x2000,data);
461497         break;
462498      }
499      case 0x38:
500      {
501         // TVRAM
502         ram[offset+cur_bank*0x2000] = data;
503         break;
504      }
463505      case 0x39:
464506      {
507         ram[offset+cur_bank*0x2000] = data;
465508         if(kanji_bank & 0x80) //kanji ROM
466509         {
467510            //NOP
r8957r8958
529572
530573   bank_val[bank_addr] = data & 0x3f;
531574
532   //printf("%02x %02x\n",data & 0x3f,bank_addr);
533
534575//  if((data*2) >= 0x70)
535576//  printf("%s %02x\n",bank_name[bank_addr],bank_val[bank_addr]*2);
536577
r8957r8958
562603[1] xxxx xxxx TV map offset low address value
563604[2] ---- -xxx TV map offset high address value
564605
565[9] ---- xxxx vertical scrolling? (val * 2)
606[9] ---- xxxx vertical scrolling shift position
566607*/
567608
568609static UINT8 pal_256_param(int index, int param)
r8957r8958
658699   irq_mask[2] = (data & 0x02); //printer
659700   irq_mask[3] = (data & 0x01); //RP5c15
660701
661   printf("%02x\n",data);
702//   printf("%02x\n",data);
662703}
663704
664705static WRITE8_HANDLER( mz2500_irq_data_w )
r8957r8958
889930      hs = (cg_reg[0x0c] & 0x7f)*8;
890931      he = (cg_reg[0x0d] & 0x7f)*8;
891932
892      popmessage("%d %d %d %d %02x",vs,ve,hs,he,cg_reg[0x0e]);
933      //popmessage("%d %d %d %d %02x",vs,ve,hs,he,cg_reg[0x0e]);
893934
894935      space->machine->primary_screen->configure(720, 480, visarea, space->machine->primary_screen->frame_period().attoseconds); //TODO
895936   }
r8957r8958
15241565   ROM_REGION( 0x40000, "dictionary", 0 )
15251566   ROM_LOAD( "dict.rom", 0x00000, 0x40000, CRC(aa957c2b) SHA1(19a5ba85055f048a84ed4e8d471aaff70fcf0374) )
15261567
1527   ROM_REGION( 0x2000, "pcg", ROMREGION_ERASEFF )
1568   ROM_REGION( 0x2000, "pcg", ROMREGION_ERASE00 )
15281569
15291570   ROM_REGION( 0x8000, "rom", ROMREGION_ERASEFF )
15301571   ROM_LOAD( "file.rom", 0x00000, 0x8000, CRC(a7bf39ce) SHA1(3f4a237fc4f34bac6fe2bbda4ce4d16d42400081) ) //optional?

Previous 15994 Revisions Next


© 1998-2018 The MESS Team