src/mess/video/vtvideo.c
| r4618 | r4619 | |
| 29 | 29 | struct _vt_video_t |
| 30 | 30 | { |
| 31 | 31 | devcb_resolved_read8 in_ram_func; |
| 32 | devcb_resolved_write8 clear_video_interrupt; |
| 32 | 33 | |
| 33 | 34 | const device_config *screen; /* screen */ |
| 34 | 35 | UINT8 *gfx; /* content of char rom */ |
| 35 | | |
| 36 | | int skip_lines; |
| 37 | | int height; |
| 38 | | int width; |
| 36 | |
| 39 | 37 | int lba7; |
| 38 | |
| 39 | // dc012 attributes |
| 40 | UINT8 scroll_latch; |
| 41 | UINT8 blink_flip_flop; |
| 42 | UINT8 reverse_field; |
| 43 | UINT8 basic_attribute; |
| 44 | // dc011 attributes |
| 45 | UINT8 columns; |
| 46 | UINT8 height; |
| 47 | UINT8 skip_lines; |
| 48 | UINT8 frequency; |
| 49 | UINT8 interlaced; |
| 40 | 50 | }; |
| 41 | 51 | |
| 42 | 52 | /*************************************************************************** |
| r4618 | r4619 | |
| 70 | 80 | |
| 71 | 81 | WRITE8_DEVICE_HANDLER( dc012_w ) |
| 72 | 82 | { |
| 73 | | // vt_video_t *vt = get_safe_token(device); |
| 83 | vt_video_t *vt = get_safe_token(device); |
| 84 | |
| 85 | if ((data & 0x08)==0) { |
| 86 | if ((data & 0x04)==0) { |
| 87 | // set lower part scroll |
| 88 | vt->scroll_latch = (vt->scroll_latch & 0x0c) | (data & 0x03); |
| 89 | } else { |
| 90 | // set higher part scroll |
| 91 | vt->scroll_latch = (vt->scroll_latch & 0x03) | ((data & 0x03) << 2); |
| 92 | } |
| 93 | } else { |
| 94 | switch( data & 0x0f) { |
| 95 | case 0x08: |
| 96 | // toggle blink flip flop |
| 97 | vt->blink_flip_flop = (vt->blink_flip_flop==0) ? 1 : 0; |
| 98 | break; |
| 99 | case 0x09: |
| 100 | // clear vertical frequency interrupt; |
| 101 | devcb_call_write8(&vt->clear_video_interrupt, 0, 0); |
| 102 | break; |
| 103 | case 0x0A: |
| 104 | // set reverse field on |
| 105 | vt->reverse_field = 1; |
| 106 | break; |
| 107 | case 0x0B: |
| 108 | // set reverse field off |
| 109 | vt->reverse_field = 0; |
| 110 | break; |
| 111 | case 0x0C: |
| 112 | // set basic attribute to underline |
| 113 | vt->basic_attribute = 0; |
| 114 | vt->blink_flip_flop = 0; |
| 115 | break; |
| 116 | case 0x0D: |
| 117 | // set basic attribute to reverse video |
| 118 | vt->basic_attribute = 1; |
| 119 | vt->blink_flip_flop = 0; |
| 120 | break; |
| 121 | case 0x0E: |
| 122 | case 0x0F: |
| 123 | // reserved for future specification |
| 124 | vt->blink_flip_flop = 0; |
| 125 | break; |
| 126 | } |
| 127 | } |
| 74 | 128 | } |
| 75 | 129 | |
| 76 | 130 | |
| 77 | 131 | WRITE8_DEVICE_HANDLER( dc011_w ) |
| 78 | 132 | { |
| 79 | | // vt_video_t *vt = get_safe_token(device); |
| 133 | vt_video_t *vt = get_safe_token(device); |
| 134 | if (BIT(data,5)==0) { |
| 135 | if (BIT(data,4)==0) { |
| 136 | vt->columns = 80; |
| 137 | } else { |
| 138 | vt->columns = 132; |
| 139 | } |
| 140 | vt->interlaced = 1; |
| 141 | } else { |
| 142 | if (BIT(data,4)==0) { |
| 143 | vt->frequency = 60; |
| 144 | vt->skip_lines = 2; |
| 145 | } else { |
| 146 | vt->frequency = 50; |
| 147 | vt->skip_lines = 5; |
| 148 | } |
| 149 | vt->interlaced = 0; |
| 150 | } |
| 80 | 151 | } |
| 81 | 152 | |
| 82 | 153 | WRITE8_DEVICE_HANDLER( vt_video_brightness_w ) |
| r4618 | r4619 | |
| 94 | 165 | |
| 95 | 166 | for (i = 0; i < 10; i++) |
| 96 | 167 | { |
| 97 | | if (i==0) j=15; else j=i-1; |
| 168 | |
| 98 | 169 | switch(display_type) { |
| 99 | 170 | case 0 : // bottom half, double height |
| 100 | | line = vt->gfx[(code & 0x7f)*16 + (j >> 1)+5]; break; |
| 171 | j = (i >> 1)+5; break; |
| 101 | 172 | case 1 : // top half, double height |
| 102 | | line = vt->gfx[(code & 0x7f)*16 + (j >> 1)]; break; |
| 173 | j = (i >> 1); break; |
| 103 | 174 | case 2 : // double width |
| 104 | 175 | case 3 : // normal |
| 105 | | line = vt->gfx[(code & 0x7f)*16 + j]; break; |
| 176 | j = i; break; |
| 106 | 177 | } |
| 178 | // modify line since that is how it is stored in rom |
| 179 | if (j==0) j=15; else j=j-1; |
| 107 | 180 | |
| 181 | line = vt->gfx[(code & 0x7f)*16 + j]; |
| 182 | |
| 108 | 183 | for (b = 0; b < 8; b++) |
| 109 | 184 | { |
| 110 | 185 | bit = ((line << b) & 0x80) ? 1 : 0; |
| r4618 | r4619 | |
| 149 | 224 | if (code == 0x7f) { |
| 150 | 225 | // end of line, fill empty till end of line |
| 151 | 226 | if (line >= vt->skip_lines) { |
| 152 | | for(x = xpos; x < ((display_type==2) ? (vt->width / 2) : vt->width); x++ ) |
| 227 | for(x = xpos; x < ((display_type==2) ? (vt->columns / 2) : vt->columns); x++ ) |
| 153 | 228 | { |
| 154 | 229 | vt_video_display_char(device,bitmap,code,x,ypos,scroll_region,display_type); |
| 155 | 230 | } |
| r4618 | r4619 | |
| 172 | 247 | vt_video_display_char(device,bitmap,code,xpos,ypos,scroll_region,display_type); |
| 173 | 248 | } |
| 174 | 249 | xpos++; |
| 175 | | if (xpos > vt->width) { |
| 250 | if (xpos > vt->columns) { |
| 176 | 251 | line++; |
| 177 | 252 | xpos=0; |
| 178 | 253 | } |
| r4618 | r4619 | |
| 192 | 267 | |
| 193 | 268 | /* resolve callbacks */ |
| 194 | 269 | devcb_resolve_read8(&vt->in_ram_func, &intf->in_ram_func, device); |
| 270 | devcb_resolve_write8(&vt->clear_video_interrupt, &intf->clear_video_interrupt, device); |
| 195 | 271 | |
| 196 | 272 | /* get the screen device */ |
| 197 | 273 | vt->screen = devtag_get_device(device->machine, intf->screen_tag); |
| r4618 | r4619 | |
| 220 | 296 | palette_set_color_rgb(device->machine, 0, 0x00, 0x00, 0x00); // black |
| 221 | 297 | palette_set_color_rgb(device->machine, 1, 0xff, 0xff, 0xff); // white |
| 222 | 298 | |
| 223 | | vt->skip_lines = 2; // for 60Hz |
| 224 | | vt->width = 80; |
| 225 | 299 | vt->height = 24; |
| 226 | 300 | vt->lba7 = 0; |
| 227 | 301 | |
| 228 | | // LBA7 is scan line frequency update |
| 302 | vt->scroll_latch = 0; |
| 303 | vt->blink_flip_flop = 0; |
| 304 | vt->reverse_field = 0; |
| 305 | vt->basic_attribute = 0; |
| 306 | |
| 307 | vt->columns = 80; |
| 308 | vt->frequency = 60; |
| 309 | vt->interlaced = 1; |
| 310 | vt->skip_lines = 2; // for 60Hz |
| 311 | // LBA7 is scan line frequency update |
| 229 | 312 | timer_pulse(device->machine, ATTOTIME_IN_NSEC(31778), (void *) device, 0, lba7_change); |
| 230 | 313 | } |
| 231 | 314 | |