Previous 199869 Revisions Next

r21534 Saturday 2nd March, 2013 at 14:44:44 UTC by Angelo Salese
Added basic scene hook-up and RGB brightness control, fixes credit display too
[src/mame/drivers]gunpey.c

trunk/src/mame/drivers/gunpey.c
r21533r21534
210210   DECLARE_WRITE8_MEMBER(gunpey_blitter_w);
211211   DECLARE_WRITE8_MEMBER(gunpey_output_w);
212212   DECLARE_WRITE16_MEMBER(gunpey_vram_bank_w);
213   DECLARE_WRITE16_MEMBER(gunpey_vregs_addr_w);
213214   DECLARE_DRIVER_INIT(gunpey);
214215   virtual void video_start();
215216   virtual void palette_init();
r21533r21534
217218   TIMER_DEVICE_CALLBACK_MEMBER(gunpey_scanline);
218219   TIMER_CALLBACK_MEMBER(blitter_end);
219220   void gunpey_irq_check(UINT8 irq_type);
220   UINT8 draw_gfx(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int count);
221   UINT8 draw_gfx(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int count,UINT8 scene_gradient);
221222   UINT16 m_vram_bank;
223   UINT16 m_vreg_addr;
222224
223
224225   //UINT16 main_vram[0x800][0x800];
225226};
226227
r21533r21534
230231   m_blit_buffer = auto_alloc_array(machine(), UINT16, 512*512);
231232}
232233
233UINT8 gunpey_state::draw_gfx(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int count)
234UINT8 gunpey_state::draw_gfx(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int count,UINT8 scene_gradient)
234235{
235236   int x,y;
236237   int bpp_sel;
r21533r21534
241242   // do they get decompressed at blit time instead? of are there other registers we need to look at
242243
243244   // +0                    +1                    +2                    +3                    +4                    +5                    +6                    +7
244   // cccc cccc e--b b--- | xxxx x--- u--t tttt | yyyy yy-- --XX XXXX | nnnn nnnn ---Y YYYY | mmmm mmmm -MMM -NNN | hhhh hhhh wwww wwww | ---- ---- oooo oooo | pppp pppp ---- ---- |
245   // cccc cccc e--b b--- | xxxx x--- u--t tttt | yyyy yy-- --XX XXXX | nnnn nnnn ---Y YYYY | mmmm mmmm -MMM -NNN | hhhh hhhh wwww wwww | ---- ---- oooo oooo | pppp pppp ---- ---- |
245246
246247   // c = color palette
247248   // e = END marker
r21533r21534
291292//      UINT8 testhack = vram[((((ysource+0)&0x7ff)*0x800) + ((xsource+0)&0x7ff))];
292293//      UINT8 testhack2 = vram[((((ysource+0)&0x7ff)*0x800) + ((xsource+1)&0x7ff))];
293294
294      //if (m_wram[count+1] & 0x0010)
295      //if (m_wram[count+1] & 0x0010)
295296      //   color =  machine.rand()&0xf;
296297
297298
298299
299     
300
300301      UINT16 unused;
301302      if (debug) printf("sprite %04x %04x %04x %04x %04x %04x %04x %04x\n", m_wram[count+0], m_wram[count+1], m_wram[count+2], m_wram[count+3], m_wram[count+4], m_wram[count+5], m_wram[count+6], m_wram[count+7]);
302     
303
303304      unused = m_wram[count+0]&~0xff98; if (unused) printf("unused bits set in word 0 - %04x\n", unused);
304305      unused = m_wram[count+1]&~0xf89f; if (unused) printf("unused bits set in word 1 - %04x\n", unused);
305306      unused = m_wram[count+2]&~0xfc3f; if (unused) printf("unused bits set in word 2 - %04x\n", unused);
r21533r21534
308309      unused = m_wram[count+5]&~0xffff; if (unused) printf("unused bits set in word 5 - %04x\n", unused);
309310      unused = m_wram[count+6]&~0x00ff; if (unused) printf("unused bits set in word 6 - %04x\n", unused);
310311      unused = m_wram[count+7]&~0xff00; if (unused) printf("unused bits set in word 7 - %04x\n", unused);
311   
312
312313      if ((zoomwidth != sourcewidth) || (zoomheight!= zoomheight))
313314      {
314315         //printf("zoomed widths %02x %02x heights %02x %02x\n", sourcewidth, zoomwidth, sourceheight, zoomheight);
r21533r21534
338339               color_data = (vram[col_offs])|(vram[col_offs+1]<<8);
339340
340341               if(!(color_data & 0x8000))
342               {
343                  if(scene_gradient & 0x40)
344                  {
345                     int r,g,b;
346
347                     r = (color_data & 0x7c00) >> 10;
348                     g = (color_data & 0x03e0) >> 5;
349                     b = (color_data & 0x001f) >> 0;
350                     r-= (scene_gradient & 0x1f);
351                     g-= (scene_gradient & 0x1f);
352                     b-= (scene_gradient & 0x1f);
353                     if(r < 0) r = 0;
354                     if(g < 0) g = 0;
355                     if(b < 0) b = 0;
356
357                     color_data = (color_data & 0x8000) | (r << 10) | (g << 5) | (b << 0);
358                  }
359
341360                  if(cliprect.contains(x+(xi*2), y+yi))
342361                     bitmap.pix16(y+yi, x+(xi*2)) = color_data & 0x7fff;
362               }
343363
344364               pix = (data & 0xf0)>>4;
345365               col_offs = ((pix + color*0x10) & 0xff) << 1;
r21533r21534
347367               color_data = (vram[col_offs])|(vram[col_offs+1]<<8);
348368
349369               if(!(color_data & 0x8000))
370               {
371                  if(scene_gradient & 0x40)
372                  {
373                     int r,g,b;
374
375                     r = (color_data & 0x7c00) >> 10;
376                     g = (color_data & 0x03e0) >> 5;
377                     b = (color_data & 0x001f) >> 0;
378                     r-= (scene_gradient & 0x1f);
379                     g-= (scene_gradient & 0x1f);
380                     b-= (scene_gradient & 0x1f);
381                     if(r < 0) r = 0;
382                     if(g < 0) g = 0;
383                     if(b < 0) b = 0;
384
385                     color_data = (color_data & 0x8000) | (r << 10) | (g << 5) | (b << 0);
386                  }
387
350388                  if(cliprect.contains(x+1+(xi*2), y+yi))
351389                     bitmap.pix16(y+yi, x+1+(xi*2)) = color_data & 0x7fff;
390               }
352391            }
353392         }
354393      }
r21533r21534
389428               color_data = (vram[col_offs])|(vram[col_offs+1]<<8);
390429
391430               if(!(color_data & 0x8000))
392               if(cliprect.contains(x+xi, y+yi))
393                  bitmap.pix16(y+yi, x+xi) = color_data & 0x7fff;
431               {
432                  if(scene_gradient & 0x40)
433                  {
434                     int r,g,b;
435
436                     r = (color_data & 0x7c00) >> 10;
437                     g = (color_data & 0x03e0) >> 5;
438                     b = (color_data & 0x001f) >> 0;
439                     r-= (scene_gradient & 0x1f);
440                     g-= (scene_gradient & 0x1f);
441                     b-= (scene_gradient & 0x1f);
442                     if(r < 0) r = 0;
443                     if(g < 0) g = 0;
444                     if(b < 0) b = 0;
445
446                     color_data = (color_data & 0x8000) | (r << 10) | (g << 5) | (b << 0);
447                  }
448
449                  if(cliprect.contains(x+xi, y+yi))
450                     bitmap.pix16(y+yi, x+xi) = color_data & 0x7fff;
451               }
394452            }
395453         }
396454      }
r21533r21534
407465UINT32 gunpey_state::screen_update_gunpey(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
408466{
409467   //UINT16 *blit_buffer = m_blit_buffer;
410   int count;
411468   UINT16 vram_bank = m_vram_bank & 0x7fff;
469   UINT16 vreg_addr = m_vreg_addr & 0x7fff;
412470   UINT8 end_mark;
471   int count;
472   int scene_index;
413473
414474   bitmap.fill(machine().pens[0], cliprect); //black pen
415475
416   /* last 4 entries are special, skip them for now. */
417   for(count = vram_bank/2;count<(vram_bank+0x1000)/2;count+=0x10/2)
476   if((!(m_vreg_addr & 0x8000)) || (!(m_vram_bank & 0x8000)))
477      return 0;
478
479   for(scene_index = vreg_addr/2;scene_index<(vreg_addr+0x400)/2;scene_index+=0x10/2)
418480   {
419      end_mark = draw_gfx(screen.machine(), bitmap,cliprect,count);
481      UINT16 start_offs;
482      UINT16 end_offs;
483      UINT8 scene_end_mark;
484      UINT8 scene_enabled;
485      UINT8 scene_gradient;
420486
421      if(end_mark == 0x80)
422         break;
423   }
487      start_offs = (vram_bank+(m_wram[scene_index+5] << 8))/2;
488      end_offs = (vram_bank+(m_wram[scene_index+5] << 8)+0x1000)/2; //safety check
489      scene_end_mark = m_wram[scene_index+0] & 0x80;
490      scene_enabled = m_wram[scene_index+0] & 0x01;
491      scene_gradient = m_wram[scene_index+1] & 0xff;
424492
425   for(count = (vram_bank+0x1000)/2;count<(vram_bank+0x2000)/2;count+=0x10/2)
426   {
427      end_mark = draw_gfx(screen.machine(), bitmap,cliprect,count);
493//      printf("%08x: %08x %08x %08x %08x | %08x %08x %08x %08x\n",scene_index,m_wram[scene_index+0],m_wram[scene_index+1],m_wram[scene_index+2],m_wram[scene_index+3],
494//                                                  m_wram[scene_index+4],m_wram[scene_index+5],m_wram[scene_index+6],m_wram[scene_index+7]);
428495
429      if(end_mark == 0x80)
496      if(scene_enabled)
497      {
498         for(count = start_offs;count<end_offs;count+=0x10/2)
499         {
500            end_mark = draw_gfx(screen.machine(), bitmap,cliprect,count,scene_gradient);
501
502            if(end_mark == 0x80)
503               break;
504         }
505      }
506
507      if(scene_end_mark == 0x80)
430508         break;
431509   }
432510
r21533r21534
567645   COMBINE_DATA(&m_vram_bank);
568646}
569647
648WRITE16_MEMBER(gunpey_state::gunpey_vregs_addr_w)
649{
650   COMBINE_DATA(&m_vreg_addr);
651}
652
570653/***************************************************************************************/
571654
572655static ADDRESS_MAP_START( mem_map, AS_PROGRAM, 16, gunpey_state )
r21533r21534
587670   AM_RANGE(0x7fc8, 0x7fc9) AM_READWRITE8(gunpey_status_r,  gunpey_status_w, 0xffff )
588671   AM_RANGE(0x7fd0, 0x7fdf) AM_WRITE8(gunpey_blitter_w, 0xffff )
589672   //AM_RANGE(0x7FF0, 0x7FF1) AM_RAM
673   AM_RANGE(0x7fec, 0x7fed) AM_WRITE(gunpey_vregs_addr_w)
590674   AM_RANGE(0x7fee, 0x7fef) AM_WRITE(gunpey_vram_bank_w)
591675
592676ADDRESS_MAP_END
r21533r21534
785869
786870DRIVER_INIT_MEMBER(gunpey_state,gunpey)
787871{
788//   UINT8 *rom = memregion("maincpu")->base();
789
790   /* patch SLOOOOW cycle checks ... */
791//   rom[0x848b5] = 0x7e;
792//  rom[0x848b6] = 0x03;
793//   rom[0x89657] = 0x75;
794//   rom[0x8e628] = 0x75;
795
872   // ...
796873}
797874
798GAME( 2000, gunpey, 0, gunpey, gunpey, gunpey_state, gunpey,    ROT0, "Banpresto", "Gunpey",GAME_NOT_WORKING)
875GAME( 2000, gunpey, 0, gunpey, gunpey, gunpey_state, gunpey,    ROT0, "Banpresto", "Gunpey (Japan)",GAME_NOT_WORKING)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team