Previous 15994 Revisions Next

r6708 Saturday 19th December, 2009 at 09:58:54 UTC by Barry Rodewald
[FMTOWNS] Separated TVRAM and sprite RAM into two banks. Improved 16 colour layer rendering, correctly displaying the cursor in MS-DOS.
[src/mess/drivers]fmtowns.c
[src/mess/includes]fmtowns.h
[src/mess/video]fmtowns.c

src/mess/video/fmtowns.c
r6707r6708
101101extern UINT32* towns_vram;
102102extern UINT8* towns_gfxvram;
103103extern UINT8* towns_txtvram;
104extern UINT8* towns_sprram;
104105
105106extern UINT32 towns_mainmem_enable;
106107extern UINT32 towns_ankcg_enable;
r6707r6708
388389      case 0x00:  // 0x5c8 - disable TVRAM?
389390      if(towns_tvram_enable != 0)
390391      {
391         //towns_tvram_enable = 0;
392         towns_tvram_enable = 0;
392393         return 0x80;
393394      }
394395      else
r6707r6708
487488
488489/*
489490 *  Sprite RAM, low memory
490 *  Writing to 0xc8xxx or 0xcaxxx activates TVRAM mode
491 *  Writing to I/O port 0x5c8 disables TVRAM mode
492 *     (bit 7 returns high if TVRAM mode was previously active)
491 *  Writing to 0xc8xxx or 0xcaxxx activates TVRAM
492 *  Writing to I/O port 0x5c8 disables TVRAM
493 *     (bit 7 returns high if TVRAM was previously active)
493494 *
494495 *  In TVRAM mode:
495496 *    0xc8000-0xc8fff: ASCII text (2 bytes each: ISO646 code, then attribute)
r6707r6708
503504   if(offset < 0x1000)
504505   {  // 0xc8000-0xc8fff
505506      if(towns_mainmem_enable == 0)
506         return towns_txtvram[offset];
507      {
508         if(towns_tvram_enable == 0)
509            return towns_sprram[offset];
510         else
511            return towns_txtvram[offset];
512      }
507513      else
508514         return RAM[offset + 0xc8000];
509515   }
r6707r6708
517523      {
518524         if(towns_ankcg_enable != 0 && offset < 0x2800)
519525            return ROM[0x180000 + 0x3d000 + (offset-0x2000)];
520         return towns_txtvram[offset];
526         if(towns_tvram_enable == 0)
527            return towns_sprram[offset];
528         else
529            return towns_txtvram[offset];
521530      }
522531      else
523532         return RAM[offset + 0xca000];
r6707r6708
550559   }
551560}
552561
562// Should this area return TVRAM if enabled?
563READ8_HANDLER( towns_spriteram_r)
564{
565   return towns_sprram[offset];
566}
567
568WRITE8_HANDLER( towns_spriteram_w)
569{
570   towns_sprram[offset] = data;
571}
572
553573void towns_crtc_draw_scan_layer_hicolour(bitmap_t* bitmap,const rectangle* rect,int layer,int line,int scanline)
554574{
555575   UINT32 off = 0;
r6707r6708
694714   int x;
695715   UINT8 colour;
696716   int hzoom = 1;
717   int linesize;
697718
698   if(towns_vram_page_sel != 0)
699      off = 0x20000;
719//   if(towns_vram_page_sel != 0)
720//      off = 0x20000;
721   if(layer == 0)
722      linesize = towns_crtc_reg[20] * 4;
723   else
724      linesize = towns_crtc_reg[24] * 4;
725
700726   if(layer != 0)
701727   {
702728      if(!(towns_video_reg[0] & 0x10))
703729         return;
704      off += 0x40000;
705730      off += towns_crtc_reg[21];  // initial offset
706731      if(towns_crtc_reg[27] & 0x0100)
707732         hzoom = 2;
r6707r6708
713738         hzoom = 2;
714739   }
715740
716   off += (line * ((rect->max_x - rect->min_x) / 2));  // offset at this scanline
741   off += line * linesize;
717742
718743   if(hzoom == 1)
719744   {
720745      for(x=rect->min_x;x<rect->max_x;x+=2)
721746      {
722         colour = towns_gfxvram[off] >> 4;
747         colour = towns_gfxvram[off+(layer*0x40000)] >> 4;
723748         if(colour != 0)
724749         {
725750            *BITMAP_ADDR32(bitmap,scanline,x+1) =
r6707r6708
727752               | (towns_palette_g[colour] << 8)
728753               | (towns_palette_b[colour]);
729754         }
730         colour = towns_gfxvram[off] & 0x0f;
755         colour = towns_gfxvram[off+(layer*0x40000)] & 0x0f;
731756         if(colour != 0)
732757         {
733758            *BITMAP_ADDR32(bitmap,scanline,x) =
r6707r6708
742767   {  // x2 horizontal zoom
743768      for(x=rect->min_x;x<rect->max_x;x+=4)
744769      {
745         colour = towns_gfxvram[off] >> 4;
770         if(towns_video_reg[0] & 0x10)
771            off &= 0x3ffff;  // 2 layers
772         else
773            off &= 0x7ffff;  // 1 layer
774         colour = towns_gfxvram[off+(layer*0x40000)] >> 4;
746775         if(colour != 0)
747776         {
748777            *BITMAP_ADDR32(bitmap,scanline,x+2) =
r6707r6708
754783               | (towns_palette_g[colour] << 8)
755784               | (towns_palette_b[colour]);
756785         }
757         colour = towns_gfxvram[off] & 0x0f;
786         colour = towns_gfxvram[off+(layer*0x40000)] & 0x0f;
758787         if(colour != 0)
759788         {
760789            *BITMAP_ADDR32(bitmap,scanline,x) =
r6707r6708
871900   }
872901}
873902
874VIDEO_START( towns )
903void draw_text_layer(running_machine* machine,bitmap_t* bitmap, const rectangle* rect)
875904{
876   towns_vram_wplane = 0x00;
877}
878
879VIDEO_UPDATE( towns )
880{
881   int x,y;
882   UINT8 colour;
883   UINT32 colourcode;
884   UINT8 row;  // JIS row number
885   UINT16 code;
886   int off = 0;
887
888   bitmap_fill(bitmap,cliprect,0x00000000);
889
890   if(!(towns_video_reg[1] & 0x01))
891   {
892      if(!input_code_pressed(screen->machine,KEYCODE_Q))
893         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
894      if(!input_code_pressed(screen->machine,KEYCODE_W))
895         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
896   }
897   else
898   {
899      if(!input_code_pressed(screen->machine,KEYCODE_Q))
900         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
901      if(!input_code_pressed(screen->machine,KEYCODE_W))
902         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
903   }
904
905
906   // draw text layer
907905/*
908906 *  Text layer format
909907 *  2 bytes per character at both 0xc8000 and 0xca000
r6707r6708
919917 *  at this location.  The character displayed is represented by a 2-byte
920918 *  JIS code at the same offset at 0xca000.
921919 */
922   if(towns_tvram_enable != 0)
920   int x,y;
921   UINT8 colour;
922   UINT32 colourcode;
923   UINT8 row;  // JIS row number
924   UINT16 code;
925   int off = 0;
926
927   for(y=0;y<40;y++)
923928   {
924      for(y=0;y<40;y++)
929      off = 160 * y;
930      for(x=0;x<80;x++)
925931      {
926         off = 160 * y;
927         for(x=0;x<80;x++)
932         colour = towns_txtvram[off+1] & 0x07;
933         if(towns_txtvram[off+1] & 0x20)
934         {  // Bright
935            colourcode = (((colour & 0x02) ? 0xfe : 0x00) << 16)
936               | (((colour & 0x04) ? 0xfe : 0x00) << 8)
937               | ((colour & 0x01) ? 0xfe : 0x00);
938         }
939         else
928940         {
929            colour = towns_txtvram[off+1] & 0x07;
930            if(towns_txtvram[off+1] & 0x20)
931            {  // Bright
932               colourcode = (((colour & 0x02) ? 0xfe : 0x00) << 16)
933                  | (((colour & 0x04) ? 0xfe : 0x00) << 8)
934                  | ((colour & 0x01) ? 0xfe : 0x00);
935            }
936            else
941            colourcode = (((colour & 0x02) ? 0x7f : 0x00) << 16)
942               | (((colour & 0x04) ? 0x7f : 0x00) << 8)
943               | ((colour & 0x01) ? 0x7f : 0x00);
944         }
945
946         if((towns_txtvram[off+1] & 0xc0) != 0)
947         {   // double width
948            if(towns_txtvram[off+1] & 0x40)
937949            {
938               colourcode = (((colour & 0x02) ? 0x7f : 0x00) << 16)
939                  | (((colour & 0x04) ? 0x7f : 0x00) << 8)
940                  | ((colour & 0x01) ? 0x7f : 0x00);
941            }
942
943            if((towns_txtvram[off+1] & 0xc0) != 0)
944            {   // double width
945               if(towns_txtvram[off+1] & 0x40)
950               row = (towns_txtvram[off+0x2000] - 32);
951               code = 0;
952               if(row <= 8)
946953               {
947                  row = (towns_txtvram[off+0x2000] - 32);
948                  code = 0;
949                  if(row <= 8)
950                  {
951                     code = (row & 0x07) * 0x20;
952                     code += ((towns_txtvram[off+0x2001]-32) & 0x1f)
953                           | (((towns_txtvram[off+0x2001]-32) & 0x40) << 2)
954                           | (((towns_txtvram[off+0x2001]-32) & 0x20) << 4);
955                  }
956                  if(row >= 16)  // Kanji
957                  {
958                     code = 0x400;
959                     code += ((towns_txtvram[off+0x2001]) & 0x1f)
960                           + (((towns_txtvram[off+0x2001]-32) & 0x60) << 4)
961                           + ((row & 0x0f) << 5)
962                           + (((row-16) & 0x70) * 0x60);
963                  }
964                  drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[1],code,
965                     colourcode,   0,0,towns_crtc_layerscr[0].min_x+(x*8),towns_crtc_layerscr[0].min_y+(y*16),0);
954                  code = (row & 0x07) * 0x20;
955                  code += ((towns_txtvram[off+0x2001]-32) & 0x1f)
956                        | (((towns_txtvram[off+0x2001]-32) & 0x40) << 2)
957                        | (((towns_txtvram[off+0x2001]-32) & 0x20) << 4);
966958               }
967            }
968            else
969            {
970               drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[0],towns_txtvram[off],
959               if(row >= 16)  // Kanji
960               {
961                  code = 0x400;
962                  code += ((towns_txtvram[off+0x2001]) & 0x1f)
963                        + (((towns_txtvram[off+0x2001]-32) & 0x60) << 4)
964                        + ((row & 0x0f) << 5)
965                        + (((row-16) & 0x70) * 0x60);
966               }
967               drawgfx_transpen_raw(bitmap,rect,machine->gfx[1],code,
971968                  colourcode,   0,0,towns_crtc_layerscr[0].min_x+(x*8),towns_crtc_layerscr[0].min_y+(y*16),0);
972969            }
973            off += 2;
974970         }
971         else
972         {
973            drawgfx_transpen_raw(bitmap,rect,machine->gfx[0],towns_txtvram[off],
974               colourcode,   0,0,towns_crtc_layerscr[0].min_x+(x*8),towns_crtc_layerscr[0].min_y+(y*16),0);
975         }
976         off += 2;
975977      }
976978   }
979}
977980
981VIDEO_START( towns )
982{
983   towns_vram_wplane = 0x00;
984}
985
986VIDEO_UPDATE( towns )
987{
988   bitmap_fill(bitmap,cliprect,0x00000000);
989
990   if(!(towns_video_reg[1] & 0x01))
991   {
992      if(!input_code_pressed(screen->machine,KEYCODE_Q))
993         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
994      if(!input_code_pressed(screen->machine,KEYCODE_W))
995         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
996   }
997   else
998   {
999      if(!input_code_pressed(screen->machine,KEYCODE_Q))
1000         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
1001      if(!input_code_pressed(screen->machine,KEYCODE_W))
1002         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
1003   }
1004
1005   draw_text_layer(screen->machine,bitmap,cliprect);
1006
9781007#ifdef CRTC_REG_DISP
9791008   popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\n%i %i %i %i | %i %i %i %i\nZOOM: %04x\nVideo: %02x %02x\nText=%i",
9801009      towns_crtc_reg[0],towns_crtc_reg[1],towns_crtc_reg[2],towns_crtc_reg[3],
src/mess/includes/fmtowns.h
r6707r6708
1919WRITE8_HANDLER(towns_video_ff81_w);
2020READ8_HANDLER(towns_spriteram_low_r);
2121WRITE8_HANDLER(towns_spriteram_low_w);
22READ8_HANDLER( towns_spriteram_r);
23WRITE8_HANDLER( towns_spriteram_w);
2224
25
2326void towns_update_video_banks(const address_space*);
2427
2528VIDEO_START( towns );
src/mess/drivers/fmtowns.c
r6707r6708
138138UINT32* towns_vram;
139139UINT8* towns_gfxvram;
140140UINT8* towns_txtvram;
141UINT8* towns_sprram;
141142static int towns_selected_drive;
142143static UINT8 towns_fdc_irq6mask;
143144static UINT8* towns_serial_rom;
r6707r6708
16331634  AM_RANGE(0x00f00000, 0x00f7ffff) AM_ROM AM_REGION("user",0x180000)  // FONT
16341635  AM_RANGE(0x00fc0000, 0x00ffffff) AM_ROM AM_REGION("user",0x200000)  // SYSTEM ROM
16351636  AM_RANGE(0x80000000, 0x8007ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x180000) // VRAM
1636  AM_RANGE(0x81000000, 0x8101ffff) AM_RAM // Sprite RAM
1637  AM_RANGE(0x81000000, 0x8101ffff) AM_READWRITE8(towns_spriteram_r,towns_spriteram_w,0xffffffff) // Sprite RAM
16371638  AM_RANGE(0xc2000000, 0xc207ffff) AM_ROM AM_REGION("user",0x000000)  // OS ROM
16381639  AM_RANGE(0xc2080000, 0xc20fffff) AM_ROM AM_REGION("user",0x100000)  // DIC ROM
16391640  AM_RANGE(0xc2100000, 0xc213ffff) AM_ROM AM_REGION("user",0x180000)  // FONT ROM
r6707r6708
18621863   towns_cmos = auto_alloc_array(machine,UINT8,0x2000);
18631864   towns_gfxvram = auto_alloc_array(machine,UINT8,0x80000);
18641865   towns_txtvram = auto_alloc_array(machine,UINT8,0x20000);
1866   towns_sprram = auto_alloc_array(machine,UINT8,0x20000);
18651867   towns_serial_rom = auto_alloc_array(machine,UINT8,256/8);
18661868   towns_init_serial_rom(machine);
18671869   towns_init_rtc();

Previous 15994 Revisions Next


© 1998-2018 The MESS Team