Previous 15994 Revisions Next

r10624 Tuesday 1st March, 2011 at 01:12:58 UTC by Angelo Salese
[PC-9801]: Added second uPD7220, fixed a divide by zero bug and enabled line drawing (diagonals still doesn't work correctly)
[src/mess/drivers]pc9801.c
[src/mess/video]upd7220.c

src/mess/video/upd7220.c
r10623r10624
676676
677677   //printf("%d %d %08x %04x %d %04x\n",x,y,line_size,line_pattern,upd7220->figs.dir,upd7220->pitch);
678678
679   return;
680
681679   for(i = 0;i<line_size;i++)
682680   {
683681      line_step = (upd7220->figs.d1 * i);
r10623r10624
13131311   {
13141312      UINT16 data = space->direct().read_raw_word(addr & 0x3ffff);
13151313
1316      if((sx << 4) <= upd7220->aw * 8 - 1 && y <= upd7220->al - 1)
1314      if((sx << 4) <= upd7220->aw * 16 - 1 && y <= upd7220->al - 1)
13171315         upd7220->display_func(device, bitmap, y, sx << 4, addr, data, upd7220->vram);
13181316
13191317      if (wd) addr += 2; else addr++;
r10623r10624
13471345
13481346      for (y = 0; y < len; y++)
13491347      {
1350         addr = (sad & 0x1ffff) + (y * upd7220->pitch); //TODO: sad needs to be & 0x3ffff
1348         addr = (sad & 0x3ffff) + (y * upd7220->pitch); //TODO: sad needs to be & 0x3ffff
13511349
1352         if (im || force_bitmap)
1350         if ((im || force_bitmap) && upd7220->display_func)
13531351            draw_graphics_line(device, bitmap, addr, y + bsy, wd);
13541352         else
13551353         {
r10623r10624
13581356         }
13591357      }
13601358
1361      tsy += (y / upd7220->lr);
1359      if(upd7220->lr)
1360         tsy += (y / upd7220->lr);
13621361      bsy += y;
13631362   }
13641363}
src/mess/drivers/pc9801.c
r10623r10624
3030public:
3131   pc9801_state(running_machine &machine, const driver_device_config_base &config)
3232      : driver_device(machine, config),
33        m_hgdc(*this, "upd7220_chr")
33       m_hgdc1(*this, "upd7220_chr"),
34       m_hgdc2(*this, "upd7220_btm")
3435      { }
3536
36   required_device<device_t> m_hgdc;
37   required_device<device_t> m_hgdc1;
38   required_device<device_t> m_hgdc2;
3739
3840   virtual void video_start();
3941   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
r10623r10624
4951   UINT8 pal_clut[4];
5052
5153   UINT8 *tvram;
54   UINT16 *gvram;
5255
5356   UINT16 font_addr;
5457   UINT8 font_line;
r10623r10624
7275   //pc9801_state *state = machine->driver_data<pc9801_state>();
7376
7477   tvram = auto_alloc_array(machine, UINT8, 0x4000);
78   gvram = auto_alloc_array(machine, UINT16, 0x18000);
7579
7680   // find memory regions
7781   m_char_rom = machine->region("chargen")->base();
r10623r10624
8488   bitmap_fill(&bitmap, &cliprect, 0);
8589
8690   /* graphics */
87   upd7220_update(m_hgdc, &bitmap, &cliprect);
91   upd7220_update(m_hgdc2, &bitmap, &cliprect);
92   upd7220_update(m_hgdc1, &bitmap, &cliprect);
8893
8994   return 0;
9095}
9196
9297static UPD7220_DISPLAY_PIXELS( hgdc_display_pixels )
9398{
94   // ...
99   int xi;
100   UINT8 pen;
101
102   for(xi=0;xi<16;xi++)
103   {
104      pen = ((vram[address + 0x04000] >> xi) & 1) ? 1 : 0;
105      pen|= ((vram[address + 0x08000] >> xi) & 1) ? 2 : 0;
106      pen|= ((vram[address + 0x0c000] >> xi) & 1) ? 4 : 0;
107
108      if(x + xi > 640 - 1 || y > 200 - 1)
109         continue;
110
111      *BITMAP_ADDR16(bitmap, y, x + xi) = pen + 8;
112   }
95113}
96114
97115static UPD7220_DRAW_TEXT_LINE( hgdc_draw_text )
r10623r10624
161179         }
162180      }
163181   }
164
165   /* old code, for reference */
166   #if 0
167   printf("%d %d\n",y,lr);
168
169   x_width = state->video_ff[WIDTH40_REG] ? 40 : 80;
170
171   for(x=0;x<x_width;x++)
172   {
173      UINT8 tile,attr,pen;
174      UINT8 secret,reverse,color,u_line,v_line;
175
176      tile = vram[(addr+x)*(state->video_ff[WIDTH40_REG]+1)] & 0xff;
177      attr = (vram[(addr+x)*(state->video_ff[WIDTH40_REG]+1)] & 0xff00) >> 8;
178      secret = (attr & 1) ^ 1;
179      //blink = attr & 2;
180      reverse = attr & 4;
181      u_line = attr & 8;
182      v_line = attr & 0x10;
183      color = (attr & 0xe0) >> 5;
184
185      for(yi=0;yi<lr;yi++)
186      {
187         for(xi=0;xi<8;xi++)
188         {
189            int res_x,res_y;
190            UINT8 tile_data;
191
192            res_x = (x*8+xi)*(state->video_ff[WIDTH40_REG]+1);
193            res_y = y*8+yi;
194
195            if(res_x > screen_max_x || res_y > screen_max_y)
196               continue;
197
198            tile_data = secret ? 0 : (state->m_char_rom[tile*8+yi]);
199
200            if(reverse) { tile_data^=0xff; }
201            if(u_line && yi == 7) { tile_data = 0xff; }
202            if(v_line)   { tile_data|=8; }
203
204            if(yi >= 16)
205               pen = 0;
206            else
207               pen = (tile_data >> (7-xi) & 1) ? color : 0;
208
209            *BITMAP_ADDR16(bitmap, res_y, res_x) = pen;
210            if(state->video_ff[WIDTH40_REG])
211            {
212               if(res_x+1 > screen_max_x || res_y > screen_max_y)
213                  continue;
214
215               *BITMAP_ADDR16(bitmap, res_y, res_x+1) = pen;
216            }
217         }
218      }
219   }
220   #endif
221182}
222183
223184
224static UPD7220_INTERFACE( hgdc_intf )
185static UPD7220_INTERFACE( hgdc_1_intf )
225186{
226187   "screen",
227   hgdc_display_pixels, //TODO: needs NULL
188   NULL,
228189   hgdc_draw_text,
229190   DEVCB_NULL,
230191   DEVCB_NULL,
231192   DEVCB_NULL
232193};
233194
195static UPD7220_INTERFACE( hgdc_2_intf )
196{
197   "screen",
198   hgdc_display_pixels,
199   NULL,
200   DEVCB_NULL,
201   DEVCB_NULL,
202   DEVCB_NULL
203};
234204
205
235206#if 0
236207static READ8_HANDLER( pc9801_xx_r )
237208{
r10623r10624
547518      switch(offset & 0xe)
548519      {
549520         case 0x00:
550         {
551            UINT8 vsync = input_port_read(space->machine, "VBLANK") & 0x20;
521            UINT8 v_sync;
552522
553            return 4 | vsync; //upd7220 bitmap port
554         }
555         case 0x02: return 0xff; //upd7220 bitmap port
523            v_sync = upd7220_r(space->machine->device("upd7220_chr"),(offset & 2) >> 1) & 0x20; //TODO: support it into the core
524
525            return (upd7220_r(space->machine->device("upd7220_btm"),(offset & 2) >> 1) & 0xdf) | v_sync;
526         case 0x02:
527            return upd7220_r(space->machine->device("upd7220_btm"),(offset & 2) >> 1);
556528         /* bitmap palette clut read */
557529         case 0x08:
558530         case 0x0a:
r10623r10624
591563      {
592564         case 0x00:
593565         case 0x02:
594            return; //upd7220 bitmap port
566            upd7220_w(space->machine->device("upd7220_btm"),(offset & 2) >> 1,data);
567            return;
595568         case 0x04:
596569         case 0x06:
597570            //if(data)
r10623r10624
719692   UINT16 write_vram;
720693
721694   if(offset < (0x3fe2/2) || state->video_ff[MEMSW_REG])
722      COMBINE_DATA(&state->tvram[offset]); //TODO: remove this
695      COMBINE_DATA(&state->tvram[offset]); //TODO: remove this?
723696
724697   write_vram = (state->tvram[(offset & 0x0fff)] & 0xff);
725698   write_vram|= (state->tvram[(offset & 0x0fff) | 0x1000] << 8);
r10623r10624
727700   upd7220_vram_w(space->machine->device("upd7220_chr"),(offset & 0x0fff), write_vram,0xffff);
728701}
729702
703static READ16_HANDLER( pc9801_gvram_r )
704{
705   //pc9801_state *state = space->machine->driver_data<pc9801_state>();
706
707   return upd7220_vram_r(space->machine->device("upd7220_btm"),offset+0x4000,mem_mask);
708}
709
710static WRITE16_HANDLER( pc9801_gvram_w )
711{
712   pc9801_state *state = space->machine->driver_data<pc9801_state>();
713
714   COMBINE_DATA(&state->gvram[offset]);
715
716   upd7220_vram_w(space->machine->device("upd7220_btm"),offset+0x4000, state->gvram[offset],mem_mask);
717}
718
730719static ADDRESS_MAP_START( pc9801_map, ADDRESS_SPACE_PROGRAM, 16)
731720   AM_RANGE(0x00000, 0x9ffff) AM_RAM //work RAM
732721   AM_RANGE(0xa0000, 0xa3fff) AM_READWRITE(pc9801_tvram_r,pc9801_tvram_w) //TVRAM
733   AM_RANGE(0xa8000, 0xbffff) AM_RAM //bitmap VRAM
722   AM_RANGE(0xa8000, 0xbffff) AM_READWRITE(pc9801_gvram_r,pc9801_gvram_w) //bitmap VRAM
734723//  AM_RANGE(0xcc000, 0xcdfff) AM_ROM //sound BIOS
735724   AM_RANGE(0xd6000, 0xd6fff) AM_ROM AM_REGION("fdc_bios_2dd",0) //floppy BIOS 2dd
736725//  AM_RANGE(0xd7000, 0xd7fff) AM_ROM AM_REGION("fdc_bios_2hd",0) //floppy BIOS 2hd
r10623r10624
756745//  AM_RANGE(0x0188, 0x018b) ym2203 opn / <undefined>
757746ADDRESS_MAP_END
758747
759static ADDRESS_MAP_START( upd7220_map, 0, 16 )
748static ADDRESS_MAP_START( upd7220_1_map, 0, 16 )
760749   AM_RANGE(0x00000, 0x3ffff) AM_DEVREADWRITE("upd7220_chr",upd7220_vram_r,upd7220_vram_w)
761750ADDRESS_MAP_END
762751
752static ADDRESS_MAP_START( upd7220_2_map, 0, 16 )
753   AM_RANGE(0x00000, 0x3ffff) AM_DEVREADWRITE("upd7220_btm",upd7220_vram_r,upd7220_vram_w)
754ADDRESS_MAP_END
763755
764756/* keyboard code */
765757/* TODO: key repeat, key modifiers, remove port impulse! */
r10623r10624
13601352   MCFG_SCREEN_SIZE(640, 480)
13611353   MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1)
13621354
1363   MCFG_UPD7220_ADD("upd7220_chr", 5000000/2, hgdc_intf, upd7220_map)
1364//   MCFG_UPD7220_ADD("upd7220_bm", 5000000/2, hgdc_intf, upd7220_map)
1355   MCFG_UPD7220_ADD("upd7220_chr", 5000000/2, hgdc_1_intf, upd7220_1_map)
1356   MCFG_UPD7220_ADD("upd7220_btm", 5000000/2, hgdc_2_intf, upd7220_2_map)
13651357
13661358   MCFG_PALETTE_LENGTH(16)
13671359   MCFG_PALETTE_INIT(pc9801)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team