src/emu/video/pc_vga.c
| r14302 | r14303 | |
| 129 | 129 | UINT8 *data; |
| 130 | 130 | UINT8 latch[4]; |
| 131 | 131 | } gc; |
| 132 | | struct { UINT8 index, data[0x15]; int state; } attribute; |
| 133 | 132 | |
| 133 | struct |
| 134 | { |
| 135 | UINT8 index, data[0x15]; int state; |
| 136 | UINT8 prot_bit; |
| 137 | } attribute; |
| 134 | 138 | |
| 139 | |
| 135 | 140 | struct { |
| 136 | 141 | UINT8 read_index, write_index, mask; |
| 137 | 142 | int read; |
| r14302 | r14303 | |
| 166 | 171 | |
| 167 | 172 | #define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0) |
| 168 | 173 | |
| 169 | | #define LINES_HELPER ( (vga.crtc.data[0x12] \ |
| 170 | | |((vga.crtc.data[7]&2)<<7) \ |
| 171 | | |((vga.crtc.data[7]&0x40)<<3))+1 ) |
| 172 | 174 | //#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) |
| 175 | 177 | |
| 176 | | #define GRAPHIC_MODE (vga.gc.data[6]&1) /* else textmodus */ |
| 178 | #define GRAPHIC_MODE (vga.gc.data[6]&1) /* else text mode */ |
| 177 | 179 | |
| 178 | | #define EGA_COLUMNS (vga.crtc.data[1]+1) |
| 180 | #define EGA_COLUMNS (vga.crtc.horz_disp_end+1) |
| 179 | 181 | #define EGA_START_ADDRESS (vga.crtc.start_addr) |
| 180 | 182 | #define EGA_LINE_LENGTH (vga.crtc.offset<<1) |
| 181 | 183 | |
| 182 | | #define VGA_COLUMNS (vga.crtc.data[1]+1) |
| 184 | #define VGA_COLUMNS (vga.crtc.horz_disp_end+1) |
| 183 | 185 | #define VGA_START_ADDRESS (vga.crtc.start_addr) |
| 184 | 186 | #define VGA_LINE_LENGTH (vga.crtc.offset<<3) |
| 185 | 187 | |
| 186 | 188 | #define CHAR_WIDTH ((vga.sequencer.data[1]&1)?8:9) |
| 187 | 189 | |
| 188 | | #define TEXT_COLUMNS (vga.crtc.data[1]+1) |
| 190 | #define TEXT_COLUMNS (vga.crtc.horz_disp_end+1) |
| 189 | 191 | #define TEXT_START_ADDRESS (vga.crtc.start_addr<<3) |
| 190 | 192 | #define TEXT_LINE_LENGTH (vga.crtc.offset<<1) |
| 191 | 193 | |
| 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)) |
| 193 | 195 | |
| 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 ) |
| 196 | 196 | |
| 197 | | |
| 198 | 197 | /*************************************************************************** |
| 199 | 198 | |
| 200 | 199 | Static declarations |
| r14302 | r14303 | |
| 228 | 227 | UINT32 *bitmapline; |
| 229 | 228 | int width=CHAR_WIDTH, height=CRTC_CHAR_HEIGHT; |
| 230 | 229 | int pos, line, column, mask, w, h, addr; |
| 230 | UINT8 blink_en,fore_col,back_col; |
| 231 | 231 | pen_t pen; |
| 232 | 232 | |
| 233 | 233 | if(vga.crtc.cursor_enable) |
| r14302 | r14303 | |
| 244 | 244 | attr = vga.memory[(pos<<1) + 1]; |
| 245 | 245 | font_base = 0x40000+(ch<<5); |
| 246 | 246 | 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; |
| 247 | 248 | |
| 249 | fore_col = attr & 0xf; |
| 250 | back_col = (attr & 0x70) >> 4; |
| 251 | back_col |= (vga.attribute.data[0x10]&8) ? 0 : ((attr & 0x80) >> 4); |
| 252 | |
| 248 | 253 | for (h = MAX(-line, 0); (h < height) && (line+h < MIN(TEXT_LINES, bitmap.height())); h++) |
| 249 | 254 | { |
| 250 | 255 | bitmapline = &bitmap.pix32(line+h); |
| r14302 | r14303 | |
| 253 | 258 | for (mask=0x80, w=0; (w<width)&&(w<8); w++, mask>>=1) |
| 254 | 259 | { |
| 255 | 260 | if (bits&mask) |
| 256 | | pen = vga.pens[attr & 0x0f]; |
| 261 | pen = vga.pens[blink_en ? back_col : fore_col]; |
| 257 | 262 | else |
| 258 | | pen = vga.pens[(attr & 0xf0) >> 4]; |
| 263 | pen = vga.pens[back_col]; |
| 259 | 264 | |
| 260 | 265 | if(!machine.primary_screen->visible_area().contains(column*width+w, line+h)) |
| 261 | 266 | continue; |
| r14302 | r14303 | |
| 266 | 271 | { |
| 267 | 272 | /* 9 column */ |
| 268 | 273 | if (TEXT_COPY_9COLUMN(ch)&&(bits&1)) |
| 269 | | pen = vga.pens[attr & 0x0f]; |
| 274 | pen = vga.pens[blink_en ? back_col : fore_col]; |
| 270 | 275 | else |
| 271 | | pen = vga.pens[(attr & 0xf0) >> 4]; |
| 276 | pen = vga.pens[back_col]; |
| 272 | 277 | |
| 273 | 278 | if(!machine.primary_screen->visible_area().contains(column*width+w, line+h)) |
| 274 | 279 | continue; |
| r14302 | r14303 | |
| 867 | 872 | } |
| 868 | 873 | } |
| 869 | 874 | |
| 870 | | #include "debugger.h" |
| 871 | | |
| 872 | 875 | static void seq_reg_write(running_machine &machine, UINT8 index, UINT8 data) |
| 873 | 876 | { |
| 874 | 877 | switch(index) |
| r14302 | r14303 | |
| 993 | 996 | break; |
| 994 | 997 | case 1: |
| 995 | 998 | if( vga.attribute.index & 0x20) // protection bit |
| 996 | | data = 0xff; // TODO: actually undefined |
| 999 | data = 0xff; |
| 997 | 1000 | else if ((vga.attribute.index&0x1f)<sizeof(vga.attribute.data)) |
| 998 | 1001 | data=vga.attribute.data[vga.attribute.index&0x1f]; |
| 999 | 1002 | break; |
| r14302 | r14303 | |
| 1116 | 1119 | vga_crtc_w(space, offset, data); |
| 1117 | 1120 | } |
| 1118 | 1121 | |
| 1122 | static 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 | |
| 1119 | 1142 | WRITE8_HANDLER(vga_port_03c0_w) |
| 1120 | 1143 | { |
| 1121 | 1144 | if (LOG_ACCESSES) |
| r14302 | r14303 | |
| 1129 | 1152 | } |
| 1130 | 1153 | else |
| 1131 | 1154 | { |
| 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); |
| 1135 | 1156 | } |
| 1136 | 1157 | vga.attribute.state=!vga.attribute.state; |
| 1137 | 1158 | 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 |
| 1138 | 1174 | case 2: |
| 1139 | 1175 | vga.miscellaneous_output=data; |
| 1140 | 1176 | recompute_params(space->machine()); |