Previous 15994 Revisions Next

r14303 Wednesday 1st February, 2012 at 21:44:07 UTC by Angelo Salese
Added blinking to text modes, fixed a color attribute register bug
[src/emu/video]pc_vga.c

src/emu/video/pc_vga.c
r14302r14303
129129      UINT8 *data;
130130      UINT8 latch[4];
131131   } gc;
132   struct { UINT8 index, data[0x15]; int state; } attribute;
133132
133   struct
134   {
135      UINT8 index, data[0x15]; int state;
136      UINT8 prot_bit;
137   } attribute;
134138
139
135140   struct {
136141      UINT8 read_index, write_index, mask;
137142      int read;
r14302r14303
166171
167172#define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0)
168173
169#define LINES_HELPER ( (vga.crtc.data[0x12] \
170            |((vga.crtc.data[7]&2)<<7) \
171            |((vga.crtc.data[7]&0x40)<<3))+1 )
172174//#define TEXT_LINES (LINES_HELPER)
173#define LINES (LINES_HELPER)
174#define TEXT_LINES (LINES_HELPER >> ((vga.crtc.data[9]&0x80) ? 1 : 0))
175#define LINES (vga.crtc.vert_disp_end+1)
176#define TEXT_LINES (vga.crtc.vert_disp_end+1)
175177
176#define GRAPHIC_MODE (vga.gc.data[6]&1) /* else textmodus */
178#define GRAPHIC_MODE (vga.gc.data[6]&1) /* else text mode */
177179
178#define EGA_COLUMNS (vga.crtc.data[1]+1)
180#define EGA_COLUMNS (vga.crtc.horz_disp_end+1)
179181#define EGA_START_ADDRESS (vga.crtc.start_addr)
180182#define EGA_LINE_LENGTH (vga.crtc.offset<<1)
181183
182#define VGA_COLUMNS (vga.crtc.data[1]+1)
184#define VGA_COLUMNS (vga.crtc.horz_disp_end+1)
183185#define VGA_START_ADDRESS (vga.crtc.start_addr)
184186#define VGA_LINE_LENGTH (vga.crtc.offset<<3)
185187
186188#define CHAR_WIDTH ((vga.sequencer.data[1]&1)?8:9)
187189
188#define TEXT_COLUMNS (vga.crtc.data[1]+1)
190#define TEXT_COLUMNS (vga.crtc.horz_disp_end+1)
189191#define TEXT_START_ADDRESS (vga.crtc.start_addr<<3)
190192#define TEXT_LINE_LENGTH (vga.crtc.offset<<1)
191193
192#define TEXT_COPY_9COLUMN(ch) ((ch>=192)&&(ch<=223)&&(vga.attribute.data[0x10]&4))
194#define TEXT_COPY_9COLUMN(ch) (((ch & 0xe0) == 0xc0)&&(vga.attribute.data[0x10]&4))
193195
194#define FONT1 (  ((vga.sequencer.data[3]&0x3)    |((vga.sequencer.data[3]&0x10)<<2))*0x2000 )
195#define FONT2 ( (((vga.sequencer.data[3]&0xc)>>2)|((vga.sequencer.data[3]&0x20)<<3))*0x2000 )
196196
197
198197/***************************************************************************
199198
200199    Static declarations
r14302r14303
228227   UINT32 *bitmapline;
229228   int width=CHAR_WIDTH, height=CRTC_CHAR_HEIGHT;
230229   int pos, line, column, mask, w, h, addr;
230   UINT8 blink_en,fore_col,back_col;
231231   pen_t pen;
232232
233233   if(vga.crtc.cursor_enable)
r14302r14303
244244         attr = vga.memory[(pos<<1) + 1];
245245         font_base = 0x40000+(ch<<5);
246246         font_base += ((attr & 8) ? vga.sequencer.char_sel.B : vga.sequencer.char_sel.A)*0x2000;
247         blink_en = (vga.attribute.data[0x10]&8&&machine.primary_screen->frame_number() & 0x20) ? attr & 0x80 : 0;
247248
249         fore_col = attr & 0xf;
250         back_col = (attr & 0x70) >> 4;
251         back_col |= (vga.attribute.data[0x10]&8) ? 0 : ((attr & 0x80) >> 4);
252
248253         for (h = MAX(-line, 0); (h < height) && (line+h < MIN(TEXT_LINES, bitmap.height())); h++)
249254         {
250255            bitmapline = &bitmap.pix32(line+h);
r14302r14303
253258            for (mask=0x80, w=0; (w<width)&&(w<8); w++, mask>>=1)
254259            {
255260               if (bits&mask)
256                  pen = vga.pens[attr & 0x0f];
261                  pen = vga.pens[blink_en ? back_col : fore_col];
257262               else
258                  pen = vga.pens[(attr & 0xf0) >> 4];
263                  pen = vga.pens[back_col];
259264
260265               if(!machine.primary_screen->visible_area().contains(column*width+w, line+h))
261266                  continue;
r14302r14303
266271            {
267272               /* 9 column */
268273               if (TEXT_COPY_9COLUMN(ch)&&(bits&1))
269                  pen = vga.pens[attr & 0x0f];
274                  pen = vga.pens[blink_en ? back_col : fore_col];
270275               else
271                  pen = vga.pens[(attr & 0xf0) >> 4];
276                  pen = vga.pens[back_col];
272277
273278               if(!machine.primary_screen->visible_area().contains(column*width+w, line+h))
274279                  continue;
r14302r14303
867872   }
868873}
869874
870#include "debugger.h"
871
872875static void seq_reg_write(running_machine &machine, UINT8 index, UINT8 data)
873876{
874877   switch(index)
r14302r14303
993996         break;
994997      case 1:
995998         if( vga.attribute.index & 0x20) // protection bit
996            data = 0xff; // TODO: actually undefined
999            data = 0xff;
9971000         else if ((vga.attribute.index&0x1f)<sizeof(vga.attribute.data))
9981001            data=vga.attribute.data[vga.attribute.index&0x1f];
9991002         break;
r14302r14303
11161119      vga_crtc_w(space, offset, data);
11171120}
11181121
1122static void attribute_reg_write(UINT8 index, UINT8 data)
1123{
1124   if((index & 0x30) == 0)
1125   {
1126      vga.attribute.data[index & 0x1f] = data & 0x3f;
1127   }
1128   else
1129   {
1130      switch(index & 0x1f)
1131      {
1132         /* TODO: intentional dirtiness, variable names to be properly changed */
1133         case 0x10: vga.attribute.data[0x10] = data; break;
1134         case 0x11: vga.attribute.data[0x11] = data; break;
1135         case 0x12: vga.attribute.data[0x12] = data; break;
1136         case 0x13: vga.attribute.data[0x13] = data; break;
1137         case 0x14: vga.attribute.data[0x14] = data; break;
1138      }
1139   }
1140}
1141
11191142WRITE8_HANDLER(vga_port_03c0_w)
11201143{
11211144   if (LOG_ACCESSES)
r14302r14303
11291152      }
11301153      else
11311154      {
1132         if(!(vga.attribute.index & 0x20)) // protection bit
1133            if ((vga.attribute.index&0x1f)<sizeof(vga.attribute.data))
1134               vga.attribute.data[vga.attribute.index&0x1f]=data;
1155         attribute_reg_write(vga.attribute.index,data);
11351156      }
11361157      vga.attribute.state=!vga.attribute.state;
11371158      break;
1159   #if 0
1160   case 0:
1161      if (vga.attribute.state==0)
1162      {
1163         vga.attribute.index=data & 0x1f;
1164         vga.attribute.prot_bit = data & 0x20;
1165      }
1166      else
1167      {
1168         attribute_reg_write(vga.attribute.index,data);
1169         printf("%02x %d %02x\n",vga.attribute.index,vga.attribute.prot_bit,data);
1170      }
1171      vga.attribute.state=!vga.attribute.state;
1172      break;
1173   #endif
11381174   case 2:
11391175      vga.miscellaneous_output=data;
11401176      recompute_params(space->machine());

Previous 15994 Revisions Next


© 1998-2018 The MESS Team