src/mess/includes/crtc6845.h
| r11672 | r11673 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | Motorola 6845 CRT controller and emulation |
| 4 | | |
| 5 | | This code emulates the functionality of the 6845 chip, and also |
| 6 | | supports the functionality of chips related to the 6845 |
| 7 | | |
| 8 | | Peter Trauner |
| 9 | | Nathan Woods |
| 10 | | |
| 11 | | ***************************************************************************/ |
| 12 | | |
| 13 | | #ifndef MSCRTC6845_H_ |
| 14 | | #define MSCRTC6845_H_ |
| 15 | | |
| 16 | | /*************************************************************************** |
| 17 | | |
| 18 | | Constants |
| 19 | | |
| 20 | | ***************************************************************************/ |
| 21 | | |
| 22 | | /* since this code is used to support emulations of pseudo-M6845 chips, that |
| 23 | | support functionality simlar to 6845's but are not true M6845 chips, we |
| 24 | | need to have a concept of a personality */ |
| 25 | | #define M6845_PERSONALITY_GENUINE 0 |
| 26 | | #define M6845_PERSONALITY_PC1512 1 |
| 27 | | |
| 28 | | /*************************************************************************** |
| 29 | | |
| 30 | | Type definitions |
| 31 | | |
| 32 | | ***************************************************************************/ |
| 33 | | |
| 34 | | /*----------- defined in video/crtc6845.c -----------*/ |
| 35 | | |
| 36 | | /* opaque structure representing a crtc8645 chip */ |
| 37 | | struct mscrtc6845; |
| 38 | | |
| 39 | | struct mscrtc6845_cursor |
| 40 | | { |
| 41 | | int on; |
| 42 | | int pos; |
| 43 | | int top; |
| 44 | | int bottom; |
| 45 | | }; |
| 46 | | |
| 47 | | struct mscrtc6845_config |
| 48 | | { |
| 49 | | int freq; |
| 50 | | void (*cursor_changed)(struct mscrtc6845_cursor *old); |
| 51 | | int personality; |
| 52 | | }; |
| 53 | | |
| 54 | | /*************************************************************************** |
| 55 | | |
| 56 | | Externs |
| 57 | | |
| 58 | | ***************************************************************************/ |
| 59 | | |
| 60 | | /* generic mscrtc6845 instance */ |
| 61 | | extern struct mscrtc6845 *mscrtc6845; |
| 62 | | |
| 63 | | /*************************************************************************** |
| 64 | | |
| 65 | | Prototypes |
| 66 | | |
| 67 | | ***************************************************************************/ |
| 68 | | |
| 69 | | struct mscrtc6845 *mscrtc6845_init(running_machine &machine, const struct mscrtc6845_config *config); |
| 70 | | |
| 71 | | void mscrtc6845_set_clock(struct mscrtc6845 *crtc, int freq); |
| 72 | | |
| 73 | | /* to be called before drawing screen */ |
| 74 | | void mscrtc6845_time(running_machine &machine, struct mscrtc6845 *crtc); |
| 75 | | |
| 76 | | int mscrtc6845_get_char_columns(struct mscrtc6845 *crtc); |
| 77 | | int mscrtc6845_get_char_height(struct mscrtc6845 *crtc); |
| 78 | | int mscrtc6845_get_char_lines(struct mscrtc6845 *crtc); |
| 79 | | int mscrtc6845_get_start(struct mscrtc6845 *crtc); |
| 80 | | void mscrtc6845_set_char_columns(struct mscrtc6845 *crtc, UINT8 columns); |
| 81 | | void mscrtc6845_set_char_lines(struct mscrtc6845 *crtc, UINT8 lines); |
| 82 | | |
| 83 | | int mscrtc6845_get_personality(struct mscrtc6845 *crtc); |
| 84 | | |
| 85 | | /* cursor off, cursor on, cursor 16 frames on/off, cursor 32 frames on/off |
| 86 | | start line, end line */ |
| 87 | | void mscrtc6845_get_cursor(struct mscrtc6845 *crtc, struct mscrtc6845_cursor *cursor); |
| 88 | | |
| 89 | | UINT8 mscrtc6845_port_r(struct mscrtc6845 *crtc, int offset); |
| 90 | | int mscrtc6845_port_w(struct mscrtc6845 *crtc, int offset, UINT8 data); |
| 91 | | |
| 92 | | /* to be called when writting to port */ |
| 93 | | WRITE8_HANDLER ( mscrtc6845_0_port_w ); |
| 94 | | |
| 95 | | /* to be called when reading from port */ |
| 96 | | READ8_HANDLER ( mscrtc6845_0_port_r ); |
| 97 | | |
| 98 | | /*************************************************************************** |
| 99 | | |
| 100 | | 6845 variant macros |
| 101 | | |
| 102 | | These are used to support emulations of 6845 variants, but these will |
| 103 | | be eventually merged into mscrtc6845.c so these are deprecated |
| 104 | | |
| 105 | | ***************************************************************************/ |
| 106 | | |
| 107 | | #define CRTC6845_COLUMNS (REG(0)+1) |
| 108 | | #define CRTC6845_CHAR_COLUMNS (REG(1)) |
| 109 | | #define CRTC6845_LINES (REG(4)*CRTC6845_CHAR_HEIGHT+REG(5)) |
| 110 | | #define CRTC6845_CHAR_LINES REG(6) |
| 111 | | #define CRTC6845_CHAR_HEIGHT ((REG(9)&0x1f)+1) |
| 112 | | #define CRTC6845_VIDEO_START ((REG(0xc)<<8)|REG(0xd)) |
| 113 | | #define CRTC6845_INTERLACE_MODE (REG(8)&3) |
| 114 | | #define CRTC6845_INTERLACE_SIGNAL 1 |
| 115 | | #define CRTC6845_INTERLACE 3 |
| 116 | | #define CRTC6845_CURSOR_MODE (REG(0xa)&0x60) |
| 117 | | #define CRTC6845_CURSOR_OFF 0x20 |
| 118 | | #define CRTC6845_CURSOR_16FRAMES 0x40 |
| 119 | | #define CRTC6845_CURSOR_32FRAMES 0x60 |
| 120 | | #define CRTC6845_SKEW (REG(8)&15) |
| 121 | | #define CRTC6845_CURSOR_POS ((REG(0xe)<<8)|REG(0xf)) |
| 122 | | #define CRTC6845_CURSOR_TOP (REG(0xa)&0x1f) |
| 123 | | #define CRTC6845_CURSOR_BOTTOM REG(0xb) |
| 124 | | |
| 125 | | #endif /* MSCRTC6845_H_ */ |
src/mess/video/crtc6845.c
| r11672 | r11673 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | Motorola 6845 CRT controller and emulation |
| 4 | | |
| 5 | | This code emulates the functionality of the 6845 chip, and also |
| 6 | | supports the functionality of chips related to the 6845 |
| 7 | | |
| 8 | | Peter Trauner |
| 9 | | Nathan Woods |
| 10 | | |
| 11 | | Registers |
| 12 | | 00 - Horiz. total characters |
| 13 | | 01 - Horiz. displayed characters per line |
| 14 | | 02 - Horiz. synch position |
| 15 | | 03 - Horiz. synch width in characters |
| 16 | | 04 - Vert. total lines |
| 17 | | 05 - Vert. total adjust (scan lines) |
| 18 | | 06 - Vert. displayed rows |
| 19 | | 07 - Vert. synch position (character rows) |
| 20 | | 08 - Interlace mode |
| 21 | | 09 - Maximum scan line address |
| 22 | | 0A - Cursor start (scan line) |
| 23 | | 0B - Cursor end (scan line) |
| 24 | | 0C - Start address (MSB) |
| 25 | | 0D - Start address (LSB) |
| 26 | | 0E - Cursor address (MSB) (read/write) |
| 27 | | 0F - Cursor address (LSB) (read/write) |
| 28 | | 10 - Light pen (MSB) (read only) |
| 29 | | 11 - Light pen (LSB) (read only) |
| 30 | | |
| 31 | | ***************************************************************************/ |
| 32 | | |
| 33 | | |
| 34 | | #include "emu.h" |
| 35 | | #include "includes/crtc6845.h" |
| 36 | | |
| 37 | | |
| 38 | | /*************************************************************************** |
| 39 | | |
| 40 | | Type definitions |
| 41 | | |
| 42 | | ***************************************************************************/ |
| 43 | | |
| 44 | | struct mscrtc6845 |
| 45 | | { |
| 46 | | struct mscrtc6845_config config; |
| 47 | | UINT8 reg[18]; |
| 48 | | UINT8 idx; |
| 49 | | double cursor_time; |
| 50 | | int cursor_on; |
| 51 | | }; |
| 52 | | |
| 53 | | struct reg_mask |
| 54 | | { |
| 55 | | UINT8 store_mask; |
| 56 | | UINT8 read_mask; |
| 57 | | }; |
| 58 | | |
| 59 | | struct mscrtc6845 *mscrtc6845; |
| 60 | | |
| 61 | | /*************************************************************************** |
| 62 | | |
| 63 | | Local variables |
| 64 | | |
| 65 | | ***************************************************************************/ |
| 66 | | |
| 67 | | /*------------------------------------------------- |
| 68 | | mscrtc6845_reg_mask - an array specifying how |
| 69 | | much of any given register "registers", per |
| 70 | | m6845 personality |
| 71 | | -------------------------------------------------*/ |
| 72 | | |
| 73 | | static const struct reg_mask mscrtc6845_reg_mask[2][18] = |
| 74 | | { |
| 75 | | { |
| 76 | | /* M6845_PERSONALITY_GENUINE */ |
| 77 | | { 0xff, 0x00 }, { 0xff, 0x00 }, { 0xff, 0x00 }, { 0xff, 0x00 }, |
| 78 | | { 0x7f, 0x00 }, { 0x1f, 0x00 }, { 0x7f, 0x00 }, { 0x7f, 0x00 }, |
| 79 | | { 0x3f, 0x00 }, { 0x1f, 0x00 }, { 0x7f, 0x00 }, { 0x1f, 0x00 }, |
| 80 | | { 0x3f, 0x3f }, { 0xff, 0xff }, { 0x3f, 0x3f }, { 0xff, 0xff }, |
| 81 | | { 0xff, 0x3f }, { 0xff, 0xff } |
| 82 | | }, |
| 83 | | { |
| 84 | | /* M6845_PERSONALITY_PC1512 */ |
| 85 | | { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, |
| 86 | | { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, |
| 87 | | { 0x00, 0x00 }, { 0x1f, 0x00 }, { 0x7f, 0x00 }, { 0x1f, 0x00 }, |
| 88 | | { 0x3f, 0x3f }, { 0xff, 0xff }, { 0x3f, 0x3f }, { 0xff, 0xff }, |
| 89 | | { 0xff, 0x3f }, { 0xff, 0xff } |
| 90 | | } |
| 91 | | }; |
| 92 | | |
| 93 | | /* The PC1512 has not got a full MC6845; the first 9 registers act as if they |
| 94 | | * had these hardwired values: */ |
| 95 | | static const UINT8 pc1512_defaults[] = |
| 96 | | { |
| 97 | | 113, 80, 90, 10, 127, 6, 100, 112, 2 |
| 98 | | }; |
| 99 | | |
| 100 | | /*************************************************************************** |
| 101 | | |
| 102 | | Functions |
| 103 | | |
| 104 | | ***************************************************************************/ |
| 105 | | |
| 106 | | struct mscrtc6845 *mscrtc6845_init(running_machine &machine, const struct mscrtc6845_config *config) |
| 107 | | { |
| 108 | | struct mscrtc6845 *crtc; |
| 109 | | int idx; |
| 110 | | |
| 111 | | crtc = auto_alloc_clear(machine, struct mscrtc6845); |
| 112 | | crtc->cursor_time = machine.time().as_double(); |
| 113 | | crtc->config = *config; |
| 114 | | mscrtc6845 = crtc; |
| 115 | | |
| 116 | | /* Hardwire the values which can't be changed in the PC1512 version */ |
| 117 | | if (config->personality == M6845_PERSONALITY_PC1512) |
| 118 | | { |
| 119 | | for (idx = 0; idx < sizeof(pc1512_defaults); idx++) |
| 120 | | { |
| 121 | | crtc->reg[idx] = pc1512_defaults[idx]; |
| 122 | | } |
| 123 | | } |
| 124 | | |
| 125 | | state_save_register_item_array(machine, "mscrtc6845", NULL, 0, crtc->reg); |
| 126 | | state_save_register_item(machine, "mscrtc6845", NULL, 0, crtc->idx); |
| 127 | | return crtc; |
| 128 | | } |
| 129 | | |
| 130 | | #define REG(x) (crtc->reg[x]) |
| 131 | | |
| 132 | | static int mscrtc6845_clocks_in_frame(struct mscrtc6845 *crtc) |
| 133 | | { |
| 134 | | int clocks=CRTC6845_COLUMNS*CRTC6845_LINES; |
| 135 | | switch (CRTC6845_INTERLACE_MODE) { |
| 136 | | case CRTC6845_INTERLACE_SIGNAL: // interlace generation of video signals only |
| 137 | | case CRTC6845_INTERLACE: // interlace |
| 138 | | return clocks/2; |
| 139 | | default: |
| 140 | | return clocks; |
| 141 | | } |
| 142 | | } |
| 143 | | |
| 144 | | void mscrtc6845_set_clock(struct mscrtc6845 *crtc, int freq) |
| 145 | | { |
| 146 | | assert(crtc); |
| 147 | | crtc->config.freq = freq; |
| 148 | | } |
| 149 | | |
| 150 | | void mscrtc6845_time(running_machine &machine, struct mscrtc6845 *crtc) |
| 151 | | { |
| 152 | | double neu, ftime; |
| 153 | | struct mscrtc6845_cursor cursor; |
| 154 | | |
| 155 | | neu = machine.time().as_double(); |
| 156 | | |
| 157 | | if (mscrtc6845_clocks_in_frame(crtc) == 0.0) |
| 158 | | return; |
| 159 | | |
| 160 | | ftime = mscrtc6845_clocks_in_frame(crtc) * 16.0 / crtc->config.freq; |
| 161 | | |
| 162 | | if (CRTC6845_CURSOR_MODE==CRTC6845_CURSOR_32FRAMES) |
| 163 | | ftime*=2; |
| 164 | | |
| 165 | | if (neu-crtc->cursor_time>ftime) |
| 166 | | { |
| 167 | | crtc->cursor_time += ftime; |
| 168 | | mscrtc6845_get_cursor(crtc, &cursor); |
| 169 | | |
| 170 | | if (crtc->config.cursor_changed) |
| 171 | | crtc->config.cursor_changed(&cursor); |
| 172 | | |
| 173 | | crtc->cursor_on ^= 1; |
| 174 | | } |
| 175 | | } |
| 176 | | |
| 177 | | int mscrtc6845_get_char_columns(struct mscrtc6845 *crtc) |
| 178 | | { |
| 179 | | return CRTC6845_CHAR_COLUMNS; |
| 180 | | } |
| 181 | | |
| 182 | | int mscrtc6845_get_char_height(struct mscrtc6845 *crtc) |
| 183 | | { |
| 184 | | return CRTC6845_CHAR_HEIGHT; |
| 185 | | } |
| 186 | | |
| 187 | | int mscrtc6845_get_char_lines(struct mscrtc6845 *crtc) |
| 188 | | { |
| 189 | | return CRTC6845_CHAR_LINES; |
| 190 | | } |
| 191 | | |
| 192 | | int mscrtc6845_get_start(struct mscrtc6845 *crtc) |
| 193 | | { |
| 194 | | return CRTC6845_VIDEO_START; |
| 195 | | } |
| 196 | | |
| 197 | | |
| 198 | | void mscrtc6845_set_char_columns(struct mscrtc6845 *crtc, UINT8 columns) |
| 199 | | { |
| 200 | | crtc->reg[1] = columns; |
| 201 | | } |
| 202 | | |
| 203 | | |
| 204 | | void mscrtc6845_set_char_lines(struct mscrtc6845 *crtc, UINT8 lines) |
| 205 | | { |
| 206 | | crtc->reg[6] = lines; |
| 207 | | } |
| 208 | | |
| 209 | | |
| 210 | | int mscrtc6845_get_personality(struct mscrtc6845 *crtc) |
| 211 | | { |
| 212 | | return crtc->config.personality; |
| 213 | | } |
| 214 | | |
| 215 | | void mscrtc6845_get_cursor(struct mscrtc6845 *crtc, struct mscrtc6845_cursor *cursor) |
| 216 | | { |
| 217 | | switch (CRTC6845_CURSOR_MODE) { |
| 218 | | case CRTC6845_CURSOR_OFF: |
| 219 | | cursor->on = 0; |
| 220 | | break; |
| 221 | | |
| 222 | | case CRTC6845_CURSOR_16FRAMES: |
| 223 | | case CRTC6845_CURSOR_32FRAMES: |
| 224 | | cursor->on = crtc->cursor_on; |
| 225 | | break; |
| 226 | | |
| 227 | | default: |
| 228 | | cursor->on = 1; |
| 229 | | break; |
| 230 | | } |
| 231 | | |
| 232 | | cursor->pos = CRTC6845_CURSOR_POS; |
| 233 | | cursor->top = CRTC6845_CURSOR_TOP; |
| 234 | | cursor->bottom = CRTC6845_CURSOR_BOTTOM; |
| 235 | | } |
| 236 | | |
| 237 | | UINT8 mscrtc6845_port_r(struct mscrtc6845 *crtc, int offset) |
| 238 | | { |
| 239 | | UINT8 val = 0xff; |
| 240 | | int idx; |
| 241 | | |
| 242 | | if (offset & 1) |
| 243 | | { |
| 244 | | idx = crtc->idx & 0x1f; |
| 245 | | if (idx < ARRAY_LENGTH(crtc->reg)) |
| 246 | | val = crtc->reg[idx] & mscrtc6845_reg_mask[crtc->config.personality][idx].read_mask; |
| 247 | | } |
| 248 | | else |
| 249 | | { |
| 250 | | val = crtc->idx; |
| 251 | | } |
| 252 | | return val; |
| 253 | | } |
| 254 | | |
| 255 | | int mscrtc6845_port_w(struct mscrtc6845 *crtc, int offset, UINT8 data) |
| 256 | | { |
| 257 | | struct mscrtc6845_cursor cursor; |
| 258 | | int idx; |
| 259 | | UINT8 mask; |
| 260 | | |
| 261 | | if (offset & 1) |
| 262 | | { |
| 263 | | /* write to a 6845 register, if supported */ |
| 264 | | idx = crtc->idx & 0x1f; |
| 265 | | if (idx < ARRAY_LENGTH(crtc->reg)) |
| 266 | | { |
| 267 | | mask = mscrtc6845_reg_mask[crtc->config.personality][idx].store_mask; |
| 268 | | /* Don't zero out bits not covered by the mask. */ |
| 269 | | crtc->reg[crtc->idx] &= ~mask; |
| 270 | | crtc->reg[crtc->idx] |= (data & mask); |
| 271 | | |
| 272 | | /* are there special consequences to writing to this register? */ |
| 273 | | switch (idx) { |
| 274 | | case 0xa: |
| 275 | | case 0xb: |
| 276 | | case 0xe: |
| 277 | | case 0xf: |
| 278 | | mscrtc6845_get_cursor(crtc, &cursor); |
| 279 | | if (crtc->config.cursor_changed) |
| 280 | | crtc->config.cursor_changed(&cursor); |
| 281 | | break; |
| 282 | | } |
| 283 | | |
| 284 | | /* since the PC1512 does not support the number of lines register directly, |
| 285 | | * this value is keyed off of register 9 |
| 286 | | */ |
| 287 | | if ((crtc->config.personality == M6845_PERSONALITY_PC1512) && (idx == 9)) |
| 288 | | { |
| 289 | | UINT8 char_height; |
| 290 | | char_height = mscrtc6845_get_char_height(crtc); |
| 291 | | mscrtc6845_set_char_lines(crtc, 200 ); // / char_height); |
| 292 | | } |
| 293 | | return TRUE; |
| 294 | | } |
| 295 | | } |
| 296 | | else |
| 297 | | { |
| 298 | | /* change the idx register */ |
| 299 | | crtc->idx = data; |
| 300 | | } |
| 301 | | return FALSE; |
| 302 | | } |
| 303 | | |
| 304 | | READ8_HANDLER ( mscrtc6845_0_port_r ) |
| 305 | | { |
| 306 | | return mscrtc6845_port_r(mscrtc6845, offset); |
| 307 | | } |
| 308 | | |
| 309 | | WRITE8_HANDLER ( mscrtc6845_0_port_w ) |
| 310 | | { |
| 311 | | mscrtc6845_port_w(mscrtc6845, offset, data); |
| 312 | | } |
| 313 | | |
src/mess/video/pc_vga_mess.c
| r11672 | r11673 | |
| 30 | 30 | |
| 31 | 31 | #include "emu.h" |
| 32 | 32 | #include "pc_vga_mess.h" |
| 33 | | #include "includes/crtc6845.h" |
| 34 | 33 | |
| 35 | 34 | /*************************************************************************** |
| 36 | 35 | |
| r11672 | r11673 | |
| 38 | 37 | |
| 39 | 38 | ***************************************************************************/ |
| 40 | 39 | |
| 41 | | static size_t pc_videoram_size; |
| 40 | static pc_video_update_proc (*pc_choosevideomode)(running_machine &machine, int *width, int *height); |
| 42 | 41 | |
| 43 | | static pc_video_update_proc (*pc_choosevideomode)(running_machine &machine, int *width, int *height, struct mscrtc6845 *crtc); |
| 44 | | static struct mscrtc6845 *pc_crtc; |
| 45 | | |
| 46 | 42 | static int pc_current_height; |
| 47 | 43 | static int pc_current_width; |
| 48 | 44 | /*************************************************************************** |
| r11672 | r11673 | |
| 58 | 54 | static VIDEO_START( vga ); |
| 59 | 55 | static VIDEO_RESET( vga ); |
| 60 | 56 | |
| 61 | | static pc_video_update_proc pc_vga_choosevideomode(running_machine &machine, int *width, int *height, struct mscrtc6845 *crtc); |
| 57 | static pc_video_update_proc pc_vga_choosevideomode(running_machine &machine, int *width, int *height); |
| 62 | 58 | |
| 63 | 59 | /*************************************************************************** |
| 64 | 60 | |
| r11672 | r11673 | |
| 66 | 62 | |
| 67 | 63 | ***************************************************************************/ |
| 68 | 64 | |
| 69 | | |
| 70 | | static void pc_video_postload(running_machine *machine) |
| 65 | void pc_video_start(running_machine &machine, pc_video_update_proc (*choosevideomode)(running_machine &machine, int *width, int *height)) |
| 71 | 66 | { |
| 72 | | pc_current_height = -1; |
| 73 | | pc_current_width = -1; |
| 74 | | } |
| 75 | | |
| 76 | | |
| 77 | | |
| 78 | | struct mscrtc6845 *pc_video_start(running_machine &machine, const struct mscrtc6845_config *config, |
| 79 | | pc_video_update_proc (*choosevideomode)(running_machine &machine, int *width, int *height, struct mscrtc6845 *crtc), |
| 80 | | size_t vramsize) |
| 81 | | { |
| 82 | 67 | pc_choosevideomode = choosevideomode; |
| 83 | | pc_crtc = NULL; |
| 84 | 68 | pc_current_height = -1; |
| 85 | 69 | pc_current_width = -1; |
| 86 | | machine.generic.tmpbitmap = NULL; |
| 87 | | |
| 88 | | pc_videoram_size = vramsize; |
| 89 | | if (config) |
| 90 | | { |
| 91 | | pc_crtc = mscrtc6845_init(machine, config); |
| 92 | | if (!pc_crtc) |
| 93 | | return NULL; |
| 94 | | } |
| 95 | | |
| 96 | | if (pc_videoram_size) |
| 97 | | { |
| 98 | | video_start_generic_bitmapped(machine); |
| 99 | | } |
| 100 | | |
| 101 | | machine.save().register_postload(save_prepost_delegate(FUNC(pc_video_postload), &machine)); |
| 102 | | return pc_crtc; |
| 103 | 70 | } |
| 104 | 71 | |
| 105 | 72 | |
| r11672 | r11673 | |
| 108 | 75 | { |
| 109 | 76 | UINT32 rc = 0; |
| 110 | 77 | int w = 0, h = 0; |
| 111 | | pc_video_update_proc video_update; |
| 78 | pc_video_update_proc video_update = pc_choosevideomode(screen->machine(), &w, &h); |
| 112 | 79 | |
| 113 | | if (pc_crtc) |
| 114 | | { |
| 115 | | w = mscrtc6845_get_char_columns(pc_crtc); |
| 116 | | h = mscrtc6845_get_char_height(pc_crtc) * mscrtc6845_get_char_lines(pc_crtc); |
| 117 | | } |
| 118 | | |
| 119 | | video_update = pc_choosevideomode(screen->machine(), &w, &h, pc_crtc); |
| 120 | | |
| 121 | 80 | if (video_update) |
| 122 | 81 | { |
| 123 | 82 | if ((pc_current_width != w) || (pc_current_height != h)) |
| r11672 | r11673 | |
| 139 | 98 | bitmap_fill(bitmap, cliprect, 0); |
| 140 | 99 | } |
| 141 | 100 | |
| 142 | | video_update(screen->machine().generic.tmpbitmap ? screen->machine().generic.tmpbitmap : bitmap, pc_crtc); |
| 143 | | |
| 144 | | if (screen->machine().generic.tmpbitmap) |
| 145 | | { |
| 146 | | copybitmap(bitmap, screen->machine().generic.tmpbitmap, 0, 0, 0, 0, cliprect); |
| 147 | | } |
| 101 | video_update(bitmap); |
| 148 | 102 | } |
| 149 | 103 | return rc; |
| 150 | 104 | } |
| r11672 | r11673 | |
| 224 | 178 | } vga; |
| 225 | 179 | |
| 226 | 180 | |
| 227 | | // to use the mscrtc6845 macros |
| 228 | 181 | #define REG(x) vga.crtc.data[x] |
| 229 | 182 | |
| 183 | #define CRTC_CHAR_HEIGHT ((REG(9)&0x1f)+1) |
| 184 | #define CRTC_CURSOR_MODE (REG(0xa)&0x60) |
| 185 | #define CRTC_CURSOR_OFF 0x20 |
| 186 | #define CRTC_SKEW (REG(8)&15) |
| 187 | #define CRTC_CURSOR_POS ((REG(0xe)<<8)|REG(0xf)) |
| 188 | #define CRTC_CURSOR_TOP (REG(0xa)&0x1f) |
| 189 | #define CRTC_CURSOR_BOTTOM REG(0xb) |
| 190 | |
| 230 | 191 | #define DOUBLESCAN ((vga.crtc.data[9]&0x80)||((vga.crtc.data[9]&0x1f)!=0)) |
| 231 | 192 | #define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0) |
| 232 | 193 | |
| r11672 | r11673 | |
| 250 | 211 | #define VGA_LINE_LENGTH (EGA_LINE_LENGTH<<2) |
| 251 | 212 | |
| 252 | 213 | #define CHAR_WIDTH ((vga.sequencer.data[1]&1)?8:9) |
| 253 | | //#define CHAR_HEIGHT ((vga.crtc.data[9]&0x1f)+1) |
| 254 | 214 | |
| 255 | 215 | #define TEXT_COLUMNS (vga.crtc.data[1]+1) |
| 256 | 216 | #define TEXT_START_ADDRESS (EGA_START_ADDRESS) |
| r11672 | r11673 | |
| 258 | 218 | |
| 259 | 219 | #define TEXT_COPY_9COLUMN(ch) ((ch>=192)&&(ch<=223)&&(vga.attribute.data[0x10]&4)) |
| 260 | 220 | |
| 261 | | //#define CURSOR_ON (!(vga.crtc.data[0xa]&0x20)) |
| 262 | | //#define CURSOR_STARTLINE (vga.crtc.data[0xa]&0x1f) |
| 263 | | //#define CURSOR_ENDLINE (vga.crtc.data[0xb]&0x1f) |
| 264 | | //#define CURSOR_POS (vga.crtc.data[0xf]|(vga.crtc.data[0xe]<<8)) |
| 265 | | |
| 266 | 221 | #define FONT1 ( ((vga.sequencer.data[3]&0x3) |((vga.sequencer.data[3]&0x10)<<2))*0x2000 ) |
| 267 | 222 | #define FONT2 ( (((vga.sequencer.data[3]&0xc)>>2)|((vga.sequencer.data[3]&0x20)<<3))*0x2000 ) |
| 268 | 223 | |
| r11672 | r11673 | |
| 1049 | 1004 | vga.monitor.get_sync_lines=vga_get_crtc_sync_lines; |
| 1050 | 1005 | vga.monitor.get_sync_columns=vga_get_crtc_sync_columns; |
| 1051 | 1006 | machine.scheduler().timer_pulse(attotime::from_hz(60), FUNC(vga_timer)); |
| 1052 | | pc_video_start(machine, NULL, pc_vga_choosevideomode, 0); |
| 1007 | pc_video_start(machine, pc_vga_choosevideomode); |
| 1053 | 1008 | } |
| 1054 | 1009 | |
| 1055 | 1010 | static VIDEO_RESET( vga ) |
| r11672 | r11673 | |
| 1057 | 1012 | pc_vga_reset(machine); |
| 1058 | 1013 | } |
| 1059 | 1014 | |
| 1060 | | static void vga_vh_text(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 1015 | static void vga_vh_text(bitmap_t *bitmap) |
| 1061 | 1016 | { |
| 1062 | 1017 | UINT8 ch, attr; |
| 1063 | 1018 | UINT8 bits; |
| 1064 | 1019 | UINT8 *font; |
| 1065 | 1020 | UINT16 *bitmapline; |
| 1066 | | int width=CHAR_WIDTH, height=CRTC6845_CHAR_HEIGHT; |
| 1021 | int width=CHAR_WIDTH, height=CRTC_CHAR_HEIGHT; |
| 1067 | 1022 | int pos, line, column, mask, w, h, addr; |
| 1068 | 1023 | pen_t pen; |
| 1069 | 1024 | |
| 1070 | | if (CRTC6845_CURSOR_MODE!=CRTC6845_CURSOR_OFF) |
| 1025 | if (CRTC_CURSOR_MODE!=CRTC_CURSOR_OFF) |
| 1071 | 1026 | { |
| 1072 | 1027 | if (++vga.cursor.time>=0x10) |
| 1073 | 1028 | { |
| r11672 | r11673 | |
| 1076 | 1031 | } |
| 1077 | 1032 | } |
| 1078 | 1033 | |
| 1079 | | for (addr = TEXT_START_ADDRESS, line = -CRTC6845_SKEW; line < TEXT_LINES; |
| 1034 | for (addr = TEXT_START_ADDRESS, line = -CRTC_SKEW; line < TEXT_LINES; |
| 1080 | 1035 | line += height, addr += TEXT_LINE_LENGTH) |
| 1081 | 1036 | { |
| 1082 | 1037 | for (pos = addr, column=0; column<TEXT_COLUMNS; column++, pos++) |
| r11672 | r11673 | |
| 1110 | 1065 | bitmapline[column*width+w] = pen; |
| 1111 | 1066 | } |
| 1112 | 1067 | } |
| 1113 | | if ((CRTC6845_CURSOR_MODE!=CRTC6845_CURSOR_OFF) |
| 1114 | | &&vga.cursor.visible&&(pos==CRTC6845_CURSOR_POS)) |
| 1068 | if ((CRTC_CURSOR_MODE!=CRTC_CURSOR_OFF) |
| 1069 | &&vga.cursor.visible&&(pos==CRTC_CURSOR_POS)) |
| 1115 | 1070 | { |
| 1116 | | for (h=CRTC6845_CURSOR_TOP; |
| 1117 | | (h<=CRTC6845_CURSOR_BOTTOM)&&(h<height)&&(line+h<TEXT_LINES); |
| 1071 | for (h=CRTC_CURSOR_TOP; |
| 1072 | (h<=CRTC_CURSOR_BOTTOM)&&(h<height)&&(line+h<TEXT_LINES); |
| 1118 | 1073 | h++) |
| 1119 | 1074 | { |
| 1120 | 1075 | plot_box(bitmap, column*width, line+h, width, 1, vga.pens[attr&0xf]); |
| r11672 | r11673 | |
| 1124 | 1079 | } |
| 1125 | 1080 | } |
| 1126 | 1081 | |
| 1127 | | static void vga_vh_ega(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 1082 | static void vga_vh_ega(bitmap_t *bitmap) |
| 1128 | 1083 | { |
| 1129 | 1084 | int pos, line, column, c, addr, i; |
| 1130 | | int height = CRTC6845_CHAR_HEIGHT; |
| 1085 | int height = CRTC_CHAR_HEIGHT; |
| 1131 | 1086 | UINT16 *bitmapline; |
| 1132 | 1087 | UINT16 *newbitmapline; |
| 1133 | 1088 | pen_t pen; |
| r11672 | r11673 | |
| 1169 | 1124 | } |
| 1170 | 1125 | } |
| 1171 | 1126 | |
| 1172 | | static void vga_vh_vga(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 1127 | static void vga_vh_vga(bitmap_t *bitmap) |
| 1173 | 1128 | { |
| 1174 | 1129 | int pos, line, column, c, addr, curr_addr; |
| 1175 | 1130 | UINT16 *bitmapline; |
| r11672 | r11673 | |
| 1227 | 1182 | } |
| 1228 | 1183 | } |
| 1229 | 1184 | |
| 1230 | | static pc_video_update_proc pc_vga_choosevideomode(running_machine &machine, int *width, int *height, struct mscrtc6845 *crtc) |
| 1185 | static pc_video_update_proc pc_vga_choosevideomode(running_machine &machine, int *width, int *height) |
| 1231 | 1186 | { |
| 1232 | 1187 | pc_video_update_proc proc = NULL; |
| 1233 | 1188 | int i; |