Previous 15994 Revisions Next

r9238 Monday 27th September, 2010 at 11:34:41 UTC by Barry Rodewald
[FMTOWNS] Added auto page flipping when sprite hardware is active.
[src/mess/includes]fmtowns.h
[src/mess/video]fmtowns.c

src/mess/video/fmtowns.c
r9237r9238
102102
103103//static UINT32 pshift;  // for debugging
104104
105void draw_sprites(running_machine* machine, const rectangle* rect);
106
105107void towns_crtc_refresh_mode(running_machine* machine)
106108{
107109   towns_state* state = machine->driver_data<towns_state>();
r9237r9238
415417            state->video.towns_dpmd_flag = 0;
416418            ret |= 0x80;
417419         }
418         ret |= (state->video.towns_vblank_flag ? 0x02 : 0x00);  // TODO: figure out just what this bit is...
420         ret |= (state->video.towns_sprite_flag ? 0x02 : 0x00);  // Sprite drawing flag
421         ret |= state->video.towns_sprite_page & 0x01;
419422         return ret;
420423      case 0x10:
421424         return state->video.towns_sprite_sel;
r9237r9238
720723   int xdir,ydir;
721724   int width = (state->video.towns_crtc_reg[12] - state->video.towns_crtc_reg[11]) / (((state->video.towns_crtc_reg[27] & 0x0f00) >> 8)+1);
722725   int height = (state->video.towns_crtc_reg[16] - state->video.towns_crtc_reg[15]) / (((state->video.towns_crtc_reg[27] & 0xf000) >> 12)+1);
723   UINT32 vram_start = (state->video.towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000;
724726
725727   if(xflip)
726728   {
r9237r9238
756758   {
757759      for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff)
758760      {
759         voffset = 0;
761         if(state->video.towns_sprite_page != 0)
762            voffset = 0x20000;
763         else
764            voffset = 0x00000;
760765         pixel = (state->towns_txtvram[poffset] & 0xf0) >> 4;
761766         col = state->towns_txtvram[coffset+(pixel*2)] | (state->towns_txtvram[coffset+(pixel*2)+1] << 8);
762         voffset += (state->video.towns_crtc_reg[24] * 4) * ypos;  // scanline size in bytes * y pos
767         voffset += (state->video.towns_crtc_reg[24] * 4) * (ypos & 0x1ff);  // scanline size in bytes * y pos
763768         voffset += (xpos & 0x1ff) * 2;
764769         voffset &= 0x3ffff;
765         //voffset += (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000;
766770         if(xpos < width && ypos < height && pixel != 0)
767771         {
768            state->towns_gfxvram[voffset+vram_start+1] = (col & 0xff00) >> 8;
769            state->towns_gfxvram[voffset+vram_start] = col & 0x00ff;
772            state->towns_gfxvram[0x40000+voffset+1] = (col & 0xff00) >> 8;
773            state->towns_gfxvram[0x40000+voffset] = col & 0x00ff;
770774         }
771775         if(xflip)
772776            voffset+=2;
r9237r9238
777781         voffset &= 0x3ffff;
778782         if(xpos < width && ypos < height && pixel != 0)
779783         {
780            state->towns_gfxvram[voffset+vram_start+1] = (col & 0xff00) >> 8;
781            state->towns_gfxvram[voffset+vram_start] = col & 0x00ff;
784            state->towns_gfxvram[0x40000+voffset+1] = (col & 0xff00) >> 8;
785            state->towns_gfxvram[0x40000+voffset] = col & 0x00ff;
782786         }
783787         poffset++;
784788         poffset &= 0x1ffff;
r9237r9238
831835   {
832836      for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff)
833837      {
834         voffset = (state->video.towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000;
838         if(state->video.towns_sprite_page != 0)
839            voffset = 0x20000;
840         else
841            voffset = 0x00000;
835842         col = state->towns_txtvram[poffset] | (state->towns_txtvram[poffset+1] << 8);
836         voffset += (state->video.towns_crtc_reg[24] * 4) * ypos;  // scanline size in bytes * y pos
843         voffset += (state->video.towns_crtc_reg[24] * 4) * (ypos & 0x1ff);  // scanline size in bytes * y pos
837844         voffset += (xpos & 0x1ff) * 2;
838         voffset &= 0x7ffff;
845         voffset &= 0x3ffff;
839846         if(xpos < width && ypos < height && col < 0x8000)
840847         {
841            state->towns_gfxvram[voffset+1] = (col & 0xff00) >> 8;
842            state->towns_gfxvram[voffset] = col & 0x00ff;
848            state->towns_gfxvram[0x40000+voffset+1] = (col & 0xff00) >> 8;
849            state->towns_gfxvram[0x40000+voffset] = col & 0x00ff;
843850         }
844851         poffset+=2;
845852         poffset &= 0x1ffff;
r9237r9238
861868      return;
862869
863870   // clears VRAM for each frame?
864   if(state->video.towns_sprite_reg[6] & 0x10)
871   if(state->video.towns_sprite_page == 0)
872      memset(state->towns_gfxvram+0x40000,0x80,0x20000);
873   else
865874      memset(state->towns_gfxvram+0x60000,0x80,0x20000);
866   else
867      memset(state->towns_gfxvram+0x40000,0x80,0x20000);
868875
869876   for(n=sprite_limit;n<1024;n++)
870877   {
r9237r9238
903910            render_sprite_16(machine,(poffset)&0x1ffff,x,y,attr&0x2000,attr&0x1000,rect);
904911      }
905912   }
913
914   if(state->video.towns_sprite_page == 0)  // flip VRAM page
915      state->video.towns_sprite_page = 1;
916   else
917      state->video.towns_sprite_page = 0;
918
919   state->video.towns_sprite_flag = 1;  // we are now drawing
920   timer_adjust_oneshot(state->video.sprite_timer,machine->device<cpu_device>("maincpu")->cycles_to_attotime(16 * (1025-sprite_limit)),0);
906921}
907922
908923void towns_crtc_draw_scan_layer_hicolour(running_machine* machine, bitmap_t* bitmap,const rectangle* rect,int layer,int line,int scanline)
r9237r9238
922937
923938   if(state->video.towns_display_page_sel != 0)
924939      off = 0x20000;
940
941//   if((layer == 1) && (state->video.towns_sprite_reg[1] & 0x80) && (state->video.towns_sprite_page == 1))
942//      off = 0x20000;
943
925944   if(layer != 0)
926945   {
927946      if(!(state->video.towns_video_reg[0] & 0x10))
r9237r9238
11051124
11061125   if(state->video.towns_display_page_sel != 0)
11071126      off = 0x20000;
1127
1128//   if((layer == 1) && (state->video.towns_sprite_reg[1] & 0x80) && (state->video.towns_sprite_page == 1))
1129//      off = 0x20000;
1130
11081131   if(layer == 0)
11091132      linesize = state->video.towns_crtc_reg[20] * 8;
11101133   else
r9237r9238
12721295
12731296   if(state->video.towns_display_page_sel != 0)
12741297      off = 0x20000;
1298
1299//   if((layer == 1) && (state->video.towns_sprite_reg[1] & 0x80) && (state->video.towns_sprite_page == 1))
1300//      off = 0x20000;
1301
12751302   if(layer == 0)
12761303      linesize = state->video.towns_crtc_reg[20] * 4;
12771304   else
r9237r9238
17351762   }
17361763}
17371764
1765static TIMER_CALLBACK( towns_sprite_done )
1766{
1767   // sprite drawing is complete, lower flag
1768   towns_state* state = machine->driver_data<towns_state>();
1769   state->video.towns_sprite_flag = 0;
1770   if(state->video.towns_sprite_page != 0)
1771      state->video.towns_crtc_reg[21] |= 0x8000;
1772   else
1773      state->video.towns_crtc_reg[21] &= ~0x8000;
1774}
1775
17381776static TIMER_CALLBACK( towns_vblank_end )
17391777{
17401778   // here we'll clear the vsync signal, I presume it goes low on it's own eventually
r9237r9238
17551793   timer_set(device->machine,device->machine->primary_screen->time_until_vblank_end(),(void*)dev,0,towns_vblank_end);
17561794   if(state->video.towns_tvram_enable)
17571795      draw_text_layer(dev->machine);
1758   if(state->video.towns_sprite_reg[1] & 0x80)  // if sprites are enabled, then sprites are drawn on this layer.
1796   if(state->video.towns_sprite_reg[1] & 0x80)
17591797      draw_sprites(dev->machine,&state->video.towns_crtc_layerscr[1]);
17601798}
17611799
r9237r9238
17641802   towns_state* state = machine->driver_data<towns_state>();
17651803
17661804   state->video.towns_vram_wplane = 0x00;
1805   state->video.towns_sprite_page = 0;
1806   state->video.sprite_timer = timer_alloc(machine,towns_sprite_done,NULL);
17671807}
17681808
17691809VIDEO_UPDATE( towns )
r9237r9238
18091849
18101850#ifdef CRTC_REG_DISP
18111851   popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\n%04x %i %i %i | %04x %i %i %i\nZOOM: %04x\nVideo: %02x %02x\nText=%i Spr=%02x\nReg28=%04x",
1812      towns_crtc_reg[0],towns_crtc_reg[1],towns_crtc_reg[2],towns_crtc_reg[3],
1813      towns_crtc_reg[4],towns_crtc_reg[5],towns_crtc_reg[6],towns_crtc_reg[7],
1814      towns_crtc_reg[8],
1815      towns_crtc_reg[9],towns_crtc_reg[10],towns_crtc_reg[11],towns_crtc_reg[12],
1816      towns_crtc_reg[13],towns_crtc_reg[14],towns_crtc_reg[15],towns_crtc_reg[16],
1817      towns_crtc_reg[17],towns_crtc_reg[18],towns_crtc_reg[19],towns_crtc_reg[20],
1818      towns_crtc_reg[21],towns_crtc_reg[22],towns_crtc_reg[23],towns_crtc_reg[24],
1819      towns_crtc_reg[27],towns_video_reg[0],towns_video_reg[1],towns_tvram_enable,towns_sprite_reg[1] & 0x80,
1820      towns_crtc_reg[28]);
1852      state->video.towns_crtc_reg[0],state->video.towns_crtc_reg[1],state->video.towns_crtc_reg[2],state->video.towns_crtc_reg[3],
1853      state->video.towns_crtc_reg[4],state->video.towns_crtc_reg[5],state->video.towns_crtc_reg[6],state->video.towns_crtc_reg[7],
1854      state->video.towns_crtc_reg[8],
1855      state->video.towns_crtc_reg[9],state->video.towns_crtc_reg[10],state->video.towns_crtc_reg[11],state->video.towns_crtc_reg[12],
1856      state->video.towns_crtc_reg[13],state->video.towns_crtc_reg[14],state->video.towns_crtc_reg[15],state->video.towns_crtc_reg[16],
1857      state->video.towns_crtc_reg[17],state->video.towns_crtc_reg[18],state->video.towns_crtc_reg[19],state->video.towns_crtc_reg[20],
1858      state->video.towns_crtc_reg[21],state->video.towns_crtc_reg[22],state->video.towns_crtc_reg[23],state->video.towns_crtc_reg[24],
1859      state->video.towns_crtc_reg[27],state->video.towns_video_reg[0],state->video.towns_video_reg[1],state->video.towns_tvram_enable,state->video.towns_sprite_reg[1] & 0x80,
1860      state->video.towns_crtc_reg[28]);
18211861#endif
18221862
18231863    return 0;
src/mess/includes/fmtowns.h
r9237r9238
6161   UINT8 towns_video_reg[2];
6262   UINT8 towns_sprite_sel;  // selected sprite register
6363   UINT8 towns_sprite_reg[8];
64   UINT8 towns_sprite_flag;  // sprite drawing flag
65   UINT8 towns_sprite_page;  // VRAM page (not layer) sprites are drawn to
6466   UINT8 towns_tvram_enable;
6567   UINT16 towns_kanji_offset;
6668   UINT8 towns_kanji_code_h;
r9237r9238
7072   UINT8 towns_display_page_sel;
7173   UINT8 towns_vblank_flag;
7274   UINT8 towns_layer_ctrl;
75   emu_timer* sprite_timer;
7376};
7477
7578class towns_state : public driver_device

Previous 15994 Revisions Next


© 1998-2018 The MESS Team