Deleted Added
sdiff udiff text old ( 39287 ) new ( 39591 )
full compact
1/*-
2 * Copyright (c) 1992-1998 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $Id$
29 */
30
31#include "sc.h"
32#include "apm.h"
33#include "opt_ddb.h"
34#include "opt_devfs.h"
35#include "opt_vesa.h"
36#include "opt_vm86.h"

--- 79 unchanged lines hidden (view full) ---

116 union {
117 struct old_mouse_data data;
118 struct mouse_mode mode;
119 } u;
120} old_mouse_info_t;
121
122/* XXX use sc_bcopy where video memory is concerned */
123extern void generic_bcopy(const void *, void *, size_t);
124
125static default_attr user_default = {
126 (FG_LIGHTGREY | BG_BLACK) << 8,
127 (FG_BLACK | BG_LIGHTGREY) << 8
128};
129
130static default_attr kernel_default = {
131 (FG_WHITE | BG_BLACK) << 8,

--- 156 unchanged lines hidden (view full) ---

288static void draw_mouse_image(scr_stat *scp);
289static void remove_mouse_image(scr_stat *scp);
290static void draw_cutmarking(scr_stat *scp);
291static void remove_cutmarking(scr_stat *scp);
292static void do_bell(scr_stat *scp, int pitch, int duration);
293static timeout_t blink_screen;
294#ifdef SC_SPLASH_SCREEN
295static void scsplash_init(scr_stat *scp);
296static void scsplash_saver(int show);
297#define scsplash_stick(stick) (sticky_splash = (stick))
298#else
299#define scsplash_stick(stick)
300#endif
301
302struct isa_driver scdriver = {
303 scprobe, scattach, "sc", 1

--- 17 unchanged lines hidden (view full) ---

321};
322
323/*
324 * These functions need to be before calls to them so they can be inlined.
325 */
326static void
327draw_cursor_image(scr_stat *scp)
328{
329 u_short cursor_image, *ptr = Crtat + (scp->cursor_pos - scp->scr_buf);
330 u_short prev_image;
331
332 if (ISPIXELSC(scp)) {
333 sc_bcopy(scp, scp->scr_buf, scp->cursor_pos - scp->scr_buf,
334 scp->cursor_pos - scp->scr_buf, 1);
335 return;
336 }
337
338 /* do we have a destructive cursor ? */
339 if (flags & CHAR_CURSOR) {
340 prev_image = scp->cursor_saveunder;
341 cursor_image = *ptr & 0x00ff;
342 if (cursor_image == DEAD_CHAR)
343 cursor_image = prev_image & 0x00ff;
344 cursor_image |= *(scp->cursor_pos) & 0xff00;
345 scp->cursor_saveunder = cursor_image;

--- 32 unchanged lines hidden (view full) ---

378 *ptr = cursor_image;
379}
380
381static void
382remove_cursor_image(scr_stat *scp)
383{
384 if (ISPIXELSC(scp))
385 sc_bcopy(scp, scp->scr_buf, scp->cursor_oldpos - scp->scr_buf,
386 scp->cursor_oldpos - scp->scr_buf, 0);
387 else
388 *(Crtat + (scp->cursor_oldpos - scp->scr_buf)) = scp->cursor_saveunder;
389}
390
391static void
392move_crsr(scr_stat *scp, int x, int y)
393{
394 if (x < 0)
395 x = 0;
396 if (y < 0)

--- 10 unchanged lines hidden (view full) ---

407static int
408scprobe(struct isa_device *dev)
409{
410 if (!scvidprobe(dev->id_unit, dev->id_flags)) {
411 if (bootverbose)
412 printf("sc%d: no video adapter is found.\n", dev->id_unit);
413 return (0);
414 }
415 (*biosvidsw.diag)(bootverbose);
416#if defined(VESA) && defined(VM86)
417 if (vesa_load())
418 return FALSE;
419 (*biosvidsw.diag)(bootverbose);
420#endif
421
422 sc_port = dev->id_iobase;
423 if (sckbdprobe(dev->id_unit, dev->id_flags))
424 return (IO_KBDSIZE);
425 else
426 return ((dev->id_flags & DETECT_KBD) ? 0 : IO_KBDSIZE);
427}
428
429/* probe video adapters, return TRUE if found */

--- 228 unchanged lines hidden (view full) ---

658 sc_alloc_cut_buffer(scp, FALSE);
659
660 /* initialize history buffer & pointers */
661 sc_alloc_history_buffer(scp, sc_history_size, 0, FALSE);
662
663#if defined(VESA) && defined(VM86)
664 if ((flags & VESA800X600)
665 && ((*biosvidsw.get_info)(scp->adp, M_VESA_800x600, &info) == 0)) {
666 sc_set_graphics_mode(scp, NULL, M_VESA_800x600);
667 sc_set_pixel_mode(scp, NULL, COL, ROW, 16);
668 initial_video_mode = M_VESA_800x600;
669 }
670#endif /* VESA && VM86 */
671
672 /* initialize cursor stuff */
673 if (!ISGRAPHSC(scp))
674 draw_cursor_image(scp);
675
676 /* get screen update going */

--- 1628 unchanged lines hidden (view full) ---

2305 return 0;
2306}
2307
2308static void
2309exchange_scr(void)
2310{
2311 move_crsr(old_scp, old_scp->xpos, old_scp->ypos);
2312 cur_console = new_scp;
2313 if (old_scp->mode != new_scp->mode || ISUNKNOWNSC(old_scp)) {
2314 if (adp_flags & V_ADP_MODECHANGE)
2315 set_mode(new_scp);
2316 }
2317 move_crsr(new_scp, new_scp->xpos, new_scp->ypos);
2318 if (ISTEXTSC(new_scp) && (flags & CHAR_CURSOR))
2319 set_destructive_cursor(new_scp);
2320 if (ISGRAPHSC(old_scp))
2321 load_palette(new_scp, palette);
2322 if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE ||
2323 old_scp->status & KBD_CODE_MODE || new_scp->status & KBD_CODE_MODE)
2324 shfts = ctls = alts = agrs = metas = accents = 0;
2325 set_border(new_scp, new_scp->border);
2326 update_leds(new_scp->status);
2327 delayed_next_scr = FALSE;
2328 mark_all(new_scp);
2329
2330 /* FIXME: the screen size may be larger than a 64K segment. */
2331 if (ISPIXELSC(new_scp))
2332 bzero(Crtat, new_scp->xpixel*new_scp->ypixel/8);
2333}
2334
2335static void
2336scan_esc(scr_stat *scp, u_char c)
2337{
2338 static u_char ansi_col[16] =
2339 {0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15};
2340 int i, n;

--- 150 unchanged lines hidden (view full) ---

2491 n = scp->term.param[0];
2492 switch (n) {
2493 case 0: /* clear form cursor to end of line */
2494 fillw(scp->term.cur_color | scr_map[0x20],
2495 scp->cursor_pos,
2496 scp->xsize - scp->xpos);
2497 mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
2498 mark_for_update(scp, scp->cursor_pos - scp->scr_buf +
2499 scp->xsize - scp->xpos);
2500 break;
2501 case 1: /* clear from beginning of line to cursor */
2502 fillw(scp->term.cur_color | scr_map[0x20],
2503 scp->cursor_pos - scp->xpos,
2504 scp->xpos + 1);
2505 mark_for_update(scp, scp->ypos * scp->xsize);
2506 mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
2507 break;
2508 case 2: /* clear entire line */
2509 fillw(scp->term.cur_color | scr_map[0x20],
2510 scp->cursor_pos - scp->xpos,
2511 scp->xsize);
2512 mark_for_update(scp, scp->ypos * scp->xsize);
2513 mark_for_update(scp, (scp->ypos + 1) * scp->xsize);
2514 break;
2515 }
2516 break;
2517
2518 case 'L': /* Insert n lines */
2519 n = scp->term.param[0]; if (n < 1) n = 1;
2520 if (n > scp->ysize - scp->ypos)
2521 n = scp->ysize - scp->ypos;

--- 28 unchanged lines hidden (view full) ---

2550 n = scp->xsize - scp->xpos;
2551 dst = scp->cursor_pos;
2552 src = dst + n;
2553 count = scp->xsize - (scp->xpos + n);
2554 bcopy(src, dst, count * sizeof(u_short));
2555 src = dst + count;
2556 fillw(scp->term.cur_color | scr_map[0x20], src, n);
2557 mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
2558 mark_for_update(scp, scp->cursor_pos - scp->scr_buf + n + count);
2559 break;
2560
2561 case '@': /* Insert n chars */
2562 n = scp->term.param[0]; if (n < 1) n = 1;
2563 if (n > scp->xsize - scp->xpos)
2564 n = scp->xsize - scp->xpos;
2565 src = scp->cursor_pos;
2566 dst = src + n;
2567 count = scp->xsize - (scp->xpos + n);
2568 bcopy(src, dst, count * sizeof(u_short));
2569 fillw(scp->term.cur_color | scr_map[0x20], src, n);
2570 mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
2571 mark_for_update(scp, scp->cursor_pos - scp->scr_buf + n + count);
2572 break;
2573
2574 case 'S': /* scroll up n lines */
2575 n = scp->term.param[0]; if (n < 1) n = 1;
2576 if (n > scp->ysize)
2577 n = scp->ysize;
2578 bcopy(scp->scr_buf + (scp->xsize * n),
2579 scp->scr_buf,

--- 19 unchanged lines hidden (view full) ---

2599
2600 case 'X': /* erase n characters in line */
2601 n = scp->term.param[0]; if (n < 1) n = 1;
2602 if (n > scp->xsize - scp->xpos)
2603 n = scp->xsize - scp->xpos;
2604 fillw(scp->term.cur_color | scr_map[0x20],
2605 scp->cursor_pos, n);
2606 mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
2607 mark_for_update(scp, scp->cursor_pos - scp->scr_buf + n);
2608 break;
2609
2610 case 'Z': /* move n tabs backwards */
2611 n = scp->term.param[0]; if (n < 1) n = 1;
2612 if ((i = scp->xpos & 0xf8) == scp->xpos)
2613 i -= 8*n;
2614 else
2615 i -= 8*(n-1);

--- 402 unchanged lines hidden (view full) ---

3018 /* set up the first console */
3019 current_default = &user_default;
3020 console[0] = &main_console;
3021 init_scp(console[0]);
3022 cur_console = console[0];
3023
3024 /* copy screen to temporary buffer */
3025 if (ISTEXTSC(console[0]))
3026 generic_bcopy(Crtat, sc_buffer,
3027 console[0]->xsize * console[0]->ysize * sizeof(u_short));
3028
3029 console[0]->scr_buf = console[0]->mouse_pos = console[0]->mouse_oldpos
3030 = sc_buffer;
3031 if (col >= console[0]->xsize)
3032 col = 0;
3033 if (row >= console[0]->ysize)
3034 row = console[0]->ysize - 1;
3035 console[0]->xpos = col;

--- 952 unchanged lines hidden (view full) ---

3988 * Always use the font page #0 on the video plane 2.
3989 * Somehow we cannot show the font in other font pages on
3990 * some video cards... XXX
3991 */
3992 (*biosvidsw.show_font)(scp->adp, 0);
3993 }
3994 mark_all(scp);
3995 }
3996 set_border(scp, scp->border);
3997
3998 /* move hardware cursor out of the way */
3999 (*biosvidsw.set_hw_cursor)(scp->adp, -1, -1);
4000
4001 return 0;
4002}
4003
4004void
4005copy_font(scr_stat *scp, int operation, int font_size, u_char *buf)
4006{
4007 /*
4008 * FONT KLUDGE:
4009 * This is an interim kludge to display correct font.
4010 * Always use the font page #0 on the video plane 2.
4011 * Somehow we cannot show the font in other font pages on
4012 * some video cards... XXX

--- 304 unchanged lines hidden (view full) ---

4317 }
4318}
4319
4320static void
4321draw_mouse_image(scr_stat *scp)
4322{
4323 u_short buffer[32];
4324 u_short xoffset, yoffset;
4325 u_short *crt_pos = Crtat + (scp->mouse_pos - scp->scr_buf);
4326 u_char *font_buffer;
4327 int font_size;
4328 int i;
4329
4330 if (scp->font_size < 14) {
4331 font_buffer = font_8;
4332 font_size = 8;
4333 } else if (scp->font_size >= 16) {

--- 55 unchanged lines hidden (view full) ---

4389 }
4390 mark_for_update(scp, scp->mouse_pos - scp->scr_buf);
4391 mark_for_update(scp, scp->mouse_pos + scp->xsize + 1 - scp->scr_buf);
4392}
4393
4394static void
4395remove_mouse_image(scr_stat *scp)
4396{
4397 u_short *crt_pos = Crtat + (scp->mouse_oldpos - scp->scr_buf);
4398
4399 if (!ISTEXTSC(scp))
4400 return;
4401 *(crt_pos) = *(scp->mouse_oldpos);
4402 *(crt_pos+1) = *(scp->mouse_oldpos+1);
4403 *(crt_pos+scp->xsize) = *(scp->mouse_oldpos+scp->xsize);
4404 *(crt_pos+scp->xsize+1) = *(scp->mouse_oldpos+scp->xsize+1);
4405 mark_for_update(scp, scp->mouse_oldpos - scp->scr_buf);
4406 mark_for_update(scp, scp->mouse_oldpos + scp->xsize + 1 - scp->scr_buf);
4407}
4408
4409static void
4410draw_cutmarking(scr_stat *scp)
4411{
4412 u_short *ptr;
4413 u_short och, nch;
4414
4415 for (ptr=scp->scr_buf; ptr<=(scp->scr_buf+(scp->xsize*scp->ysize)); ptr++) {
4416 nch = och = *(Crtat + (ptr - scp->scr_buf));
4417 /* are we outside the selected area ? */
4418 if ( ptr < (scp->mouse_cut_start > scp->mouse_cut_end ?
4419 scp->mouse_cut_end : scp->mouse_cut_start) ||
4420 ptr >= (scp->mouse_cut_start > scp->mouse_cut_end ?
4421 scp->mouse_cut_start : scp->mouse_cut_end)) {
4422 if (ptr != scp->cursor_pos)
4423 nch = (och & 0xff) | (*ptr & 0xff00);
4424 }

--- 5 unchanged lines hidden (view full) ---

4430 if (flags & CHAR_CURSOR)
4431 nch = (och & 0x88ff)|(*ptr & 0x7000)>>4|(*ptr & 0x0700)<<4;
4432 else
4433 if (!(flags & BLINK_CURSOR))
4434 nch = (och & 0xff) | (*ptr & 0xff00);
4435 }
4436 }
4437 if (nch != och)
4438 *(Crtat + (ptr - scp->scr_buf)) = nch;
4439 }
4440}
4441
4442static void
4443remove_cutmarking(scr_stat *scp)
4444{
4445 scp->mouse_cut_start = scp->mouse_cut_end = NULL;
4446 scp->status &= ~MOUSE_CUTTING;

--- 32 unchanged lines hidden (view full) ---

4479 blink_in_progress = FALSE;
4480 mark_all(scp);
4481 if (delayed_next_scr)
4482 switch_scr(scp, delayed_next_scr - 1);
4483 }
4484 else {
4485 if (blink_in_progress & 1)
4486 fillw(kernel_default.std_color | scr_map[0x20],
4487 Crtat, scp->xsize * scp->ysize);
4488 else
4489 fillw(kernel_default.rev_color | scr_map[0x20],
4490 Crtat, scp->xsize * scp->ysize);
4491 blink_in_progress--;
4492 timeout(blink_screen, scp, hz / 10);
4493 }
4494}
4495
4496void
4497sc_bcopy(scr_stat *scp, u_short *p, int from, int to, int mark)
4498{
4499 u_char *font;
4500 u_char *d, *e;
4501 u_char *f;
4502 int font_size;
4503 int line_length;
4504 int xsize;
4505 int i, j;
4506
4507 if (ISTEXTSC(scp)) {
4508 generic_bcopy(p+from, Crtat+from, (to-from+1)*sizeof (u_short));
4509 } else /* if ISPIXELSC(scp) */ {
4510 if (mark)
4511 mark = 255;
4512 font_size = scp->font_size;
4513 if (font_size < 14)
4514 font = font_8;
4515 else if (font_size >= 16)
4516 font = font_16;
4517 else
4518 font = font_14;
4519 line_length = scp->xpixel/8;
4520 xsize = scp->xsize;
4521 d = (u_char *)Crtat
4522 + scp->xoff + scp->yoff*font_size*line_length
4523 + (from%xsize) + font_size*line_length*(from/xsize);
4524 for (i = from ; i <= to ; i++) {
4525 e = d;
4526 f = &font[(p[i] & 0x00ff)*font_size];
4527 for (j = 0 ; j < font_size; j++, f++) {
4528 *e = mark^*f;
4529 e += line_length;
4530 }
4531 d++;
4532 if ((i % xsize) == xsize - 1)
4533 d += scp->xoff*2 + (font_size - 1)*line_length;
4534 }
4535 }
4536}
4537
4538#ifdef SC_SPLASH_SCREEN
4539
4540static void
4541scsplash_init(scr_stat *scp)
4542{
4543 video_info_t info;
4544
4545 /*
4546 * We currently assume the splash screen always use
4547 * VGA_CG320 mode and abort installation if this mode is not
4548 * supported with this video card. XXX
4549 */
4550 if ((*biosvidsw.get_info)(scp->adp, M_VGA_CG320, &info))
4551 return;
4552
4553 if (scsplash_load(scp) == 0 && add_scrn_saver(scsplash_saver) == 0) {
4554 default_saver = scsplash_saver;
4555 scrn_blank_time = DEFAULT_BLANKTIME;
4556 run_scrn_saver = TRUE;
4557 if (!(boothowto & (RB_VERBOSE | RB_CONFIG))) {
4558 scsplash_stick(TRUE);
4559 scsplash_saver(TRUE);
4560 }
4561 }
4562}
4563
4564static void
4565scsplash_saver(int show)
4566{
4567 if (show)
4568 scsplash(TRUE);
4569 else if (!sticky_splash)
4570 scsplash(FALSE);
4571}
4572
4573#endif /* SC_SPLASH_SCREEN */
4574
4575#endif /* NSC */