示例#1
0
int main() {
    clrscr();
    bordercolor(0);
    bgcolor(6);

    renderMenu(100);

    textcolor(7);
    gotoxy(0, 1);
    updateStatus(' ');
    cursor(1);
    while(1) {
        char c;
/*
        uint8_t row;
        uint8_t col;
        for (row = 0;  row < 16;  row++) {
            gotoxy(0, row + 3);
            cprintf("%3d ", row * 16);
            for (col = 0;  col < 16;  col++) {
                cputc(row * 16 + col);
                cputc(' ');
            }
        }
*/
        c = cgetc();

        if (c == 20) {
            // backspace
        } else if (c == 13) {
            // Return
        } else if (c == 157) {
            // Left
            uint8_t xpos = wherex() - 1;
            gotox(xpos);
        } else if (c == 29) {
            // Right
            uint8_t xpos = wherex() + 1;
            gotox(xpos);
        } else if (c == 17) {
            // Down
            uint8_t ypos = wherey() + 1;
            gotoy(ypos);
        } else if (c == 145) {
            // Up
            uint8_t ypos = wherey() - 1;
            gotoy(ypos);
        } else if (c == 19) {
            // Pos1
        } else if (c == 3) {
            // ESC -> Menu
            processMenu();
        } else {
            cputc(c);
        }        

        
        updateStatus(c);
    }
}
示例#2
0
/**
 * Initialize the screen. Set up colors and clear it.
 */
void screenInit(void)
{
    bgcolor(COLOR_BACKGROUND);
    bordercolor(COLOR_BACKGROUND);
    textcolor(COLOR_FOREGROUND);
    clrscr();
}
示例#3
0
文件: main.c 项目: gardners/synthmark
void fixscreen (void)
{
    memset((unsigned char*)0xd800, 14, 0x3e8);
    bordercolor(14);
    bgcolor(6);
    textcolor(14);
}
示例#4
0
/*-----------------------------------------------------------------------------------*/
void
ctk_draw_init(void)
{
  (void)bgcolor(SCREENCOLOR);
  (void)bordercolor(BORDERCOLOR);
  screensize(&sizex, &sizey);
  ctk_draw_clear(0, sizey);
}
示例#5
0
文件: hello.c 项目: cc65/cc65
int main (void)
{
    unsigned char XSize, YSize;

    /* Set screen colors */
    (void) textcolor (COLOR_WHITE);
    (void) bordercolor (COLOR_BLACK);
    (void) bgcolor (COLOR_BLACK);

    /* Clear the screen, put cursor in upper left corner */
    clrscr ();

    /* Ask for the screen size */
    screensize (&XSize, &YSize);

    /* Draw a border around the screen */

    /* Top line */
    cputc (CH_ULCORNER);
    chline (XSize - 2);
    cputc (CH_URCORNER);

    /* Vertical line, left side */
    cvlinexy (0, 1, YSize - 2);

    /* Bottom line */
    cputc (CH_LLCORNER);
    chline (XSize - 2);
    cputc (CH_LRCORNER);

    /* Vertical line, right side */
    cvlinexy (XSize - 1, 1, YSize - 2);

    /* Write the greeting in the mid of the screen */
    gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
    cprintf ("%s", Text);

#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)

    /* Wait for the user to press a button */
    joy_install (joy_static_stddrv);
    while (!joy_read (JOY_1)) ;
    joy_uninstall ();

#else

    /* Wait for the user to press a key */
    cgetc ();

#endif

    /* Clear the screen again */
    clrscr ();

    /* Done */
    return EXIT_SUCCESS;
}
示例#6
0
/*-----------------------------------------------------------------------------------*/
void
ctk_draw_init(void)
{
  (void)bgcolor(SCREENCOLOR);
  (void)bordercolor(BORDERCOLOR);
  (void)textcolor(WINDOWCOLOR_FOCUS);
  screensize(&sizex, &sizey);
  ctk_draw_clear(0, sizey);
  gotoxy(0, 0);
}
示例#7
0
unsigned char getData()
{
  bordercolor(2);
  //Make sure all devices are closed before opening again
  cbm_close( 2 );

  //If its a local file, use device 8
  if(url[0]=='/'){

    //remove leading '/' and add a ',s' to allow openning of a seq file
    memmove(url, url+1, strlen(url));
    strcat(url,",s");

    cbm_close( 8 );
    cbm_open( 2, 8, 2, url );
  }
  //Get local data for an already formated URL
  else if(url[strlen(url)-2]==',' && url[strlen(url)-1]=='s'){

    cbm_close( 8 );
    cbm_open( 2, 8, 2, url );
  }
  //For remote files use device 7 (Flyer)
  else{
    cbm_close( 7 );
    //
    if( cbm_open( 7, 7, 15, "" ) != 0 )
    {
      cputs("Flyer not connected!");
    }
    cbm_open( 2, 7, 2, url );
    cbm_write( 7, "http-transact:2",15);
  }

  //Clear the input buffer:
  memset(&sRecvBuf[0], 0, sizeof(sRecvBuf));

  //Read a chunk (or all if small) of the file:
  cbm_read( 2, sRecvBuf, sizeof(sRecvBuf));

  bordercolor(0);
  return(1);
}
示例#8
0
/*-----------------------------------------------------------------------------------*/
void
main(void)
{
  struct ethernet_config *ethernet_config;

  clrscr();
  bordercolor(BORDERCOLOR);
  bgcolor(SCREENCOLOR);

  process_init();

#if 1
  ethernet_config = config_read("contiki.cfg");
#else
  {
    static struct ethernet_config config = {0xD500, "cs8900a.eth"};
    uip_ipaddr_t addr;

    uip_ipaddr(&addr, 192,168,0,128);
    uip_sethostaddr(&addr);

    uip_ipaddr(&addr, 255,255,255,0);
    uip_setnetmask(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    uip_setdraddr(&addr);

    uip_ipaddr(&addr, 192,168,0,1);
    resolv_conf(&addr);

    ethernet_config = &config;
  }
#endif

  procinit_init();

  process_start((struct process *)&ethernet_process, (char *)ethernet_config);

  autostart_start(autostart_processes);

  log_message("Contiki up and running ...", "");

  while(1) {

    process_run();

    etimer_request_poll();
  }
}
示例#9
0
static void RedrawStatic (char Frame)
/* Redraw static display stuff */
{
    /* Reset the active frame */
    ActiveFrame = -1;

    /* Clear the screen hide the cursor */
    (void) bordercolor (COLOR_BORDER);
    (void) bgcolor (COLOR_BACKGROUND);
    clrscr ();
    cursor (0);

    /* Build the frame layout of the screen */
    (void) textcolor (COLOR_FRAMELOW);
    DrawFrames ();

    /* Draw the prompt line */
    HelpPrompt ();

    /* Activate the active frame */
    ActivateFrame (Frame, 0);
}
示例#10
0
文件: mouse-test.c 项目: cc65/cc65
int main (void)
#endif
{
    struct mouse_info info;
    struct mouse_box full_box, small_box;
    unsigned char width, height;
    char C;
    bool Invisible = true, Done = false, Jailed = false;

#ifdef __ATARIXL__
    cprintf ("adding heap: $%04X bytes at $%04X\r\n",
             &_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__),
             &_HIDDEN_RAM_LAST__);

    _heapadd (&_HIDDEN_RAM_LAST__, (size_t)(&_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__)));
    cgetc ();
#endif

#ifndef NO_DEBUG
    /* Initialize the debugger */
    DbgInit (0);
#endif

    /* Set dark-on-light colors.  Clear the screen. */
#ifdef __CBM__
    (void) bordercolor (COLOR_GRAY2);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_GRAY1);
#else
    (void) bordercolor (COLOR_BLUE);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_BLACK);
#endif
    cursor (0);
    clrscr ();

    /* If a lightpen driver is installed, then it can get a calibration value
    ** from this file (if it exists).  Or, the user can adjust the pen; and,
    ** the value will be put into this file, for the next time.
    ** (Other drivers will ignore this.)
    */
#if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
    pen_adjust ("pen.dat");
#endif

#if DYN_DRV
    /* If a dynamically loadable driver is named on the command line,
    ** then use that driver instead of the standard one.
    */
    if (argc > 1) {
        mouse_name = argv[1];
    } else {
#if defined(__ATARI__) || defined(__C64__) || defined(__C128__)
        char selection, flag = 0;
        cprintf ("Select mouse driver:\r\n"
                 "  0 - Joystick\r\n"
#ifdef __ATARI__
                 "  1 - ST Mouse\r\n"
                 "  2 - Amiga Mouse\r\n"
                 "  3 - Atari Trakball\r\n"
                 "  4 - Atari TouchPad\r\n"
#else
                 "  1 - 1351 Mouse\r\n"
                 "  2 - Inkwell Mouse\r\n"
                 "  3 - Paddle\r\n"
#endif
                 "Enter selection: ");
        while (1) {
            switch (selection = cgetc ()) {
            case '0': mouse_name = MSENAME_0; flag = 1; break;
            case '1': mouse_name = MSENAME_1; flag = 1; break;
            case '2': mouse_name = MSENAME_2; flag = 1; break;
            case '3': mouse_name = MSENAME_3; flag = 1; break;
#ifdef __ATARI__
            case '4': mouse_name = MSENAME_4; flag = 1; break;
#endif
            }
            if (flag) break;
        }
        cprintf ("%c\r\nOK, loading \"%s\",\r\nplease wait patiently...\r\n", selection, mouse_name);
#else
        /* Output a warning about the standard driver that is needed. */
        DoWarning ();
        mouse_name = mouse_stddrv;
#endif
    }

    /* Load and install the driver. */
    CheckError ("mouse_load_driver",
                mouse_load_driver (&MOUSE_CALLBACK, mouse_name));
#else  /* not DYN_DRV */
#if !defined(MOUSE_DRIVER) && (defined(__ATARI__) || defined(__C64__) || defined(__C128__))
    {
        char selection, flag = 0;
        cprintf ("Select mouse driver:\r\n"
                 "  0 - Joystick\r\n"
#ifdef __ATARI__
                 "  1 - ST Mouse\r\n"
                 "  2 - Amiga Mouse\r\n"
                 "  3 - Atari Trakball\r\n"
                 "  4 - Atari TouchPad\r\n"
#else
                 "  1 - 1351 Mouse\r\n"
                 "  2 - Inkwell Mouse\r\n"
                 "  3 - Paddle\r\n"
#endif
                 "Enter selection: ");
        while (1) {
            switch (selection = cgetc ()) {
            case '0': mouse_drv_use = MSESTAT_0; flag = 1; break;
            case '1': mouse_drv_use = MSESTAT_1; flag = 1; break;
            case '2': mouse_drv_use = MSESTAT_2; flag = 1; break;
            case '3': mouse_drv_use = MSESTAT_3; flag = 1; break;
#ifdef __ATARI__
            case '4': mouse_drv_use = MSESTAT_4; flag = 1; break;
#endif
            }
            if (flag) break;
        }
    }
#else
    mouse_drv_use = mouse_static_stddrv;
#endif

    /* Install the driver. */
    CheckError ("mouse_install",
                mouse_install (&MOUSE_CALLBACK,
#  ifdef MOUSE_DRIVER
                               MOUSE_DRIVER
#  else
#if defined(__ATARI__) || defined(__C64__) || defined(__C128__)
                               mouse_drv_use
#else
                               mouse_static_stddrv
#endif
#  endif
                               ));
#endif

#ifndef NO_JAIL
    /* Get the initial bounding box. */
    mouse_getbox (&full_box);
#endif

    screensize (&width, &height);

top:
    clrscr ();

    /* Print a help line */
    cputs (" d)ebug  h)ide   q)uit   s)how   j)ail");

    gotoxy (1, 20);
    cprintf ("SP: $%04X", getsp());

    /* Put a cross at the center of the screen. */
    gotoxy (width / 2 - 3, height / 2 - 1);
#if defined(__CBM__)
    cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#else
    cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#endif

    /* Test loop */
    ShowState (Jailed, Invisible);
    do {
        /* Get the current co-ordinates and button states; and, print them. */
        mouse_info (&info);
        gotoxy (0, 2);
        cprintf (" X  = %3d\r\n", info.pos.x);
        cprintf (" Y  = %3d\r\n", info.pos.y);
        cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');
        cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');

        /* Handle user input */
        if (kbhit ()) {
            cclearxy (1, 9, 23);
            switch (tolower (C = cgetc ())) {
#ifndef NO_DEBUG
                case 'd':
                    BREAK();

                    /* The debugger might have changed the colors.
                    ** Restore them.
                    */
#ifdef __CBM__
                    (void) bordercolor (COLOR_GRAY2);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_GRAY1);
#else
                    (void) bordercolor (COLOR_BLUE);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_BLACK);
#endif

                    /* The debugger changed the screen; restore it. */
                    goto top;
#endif
                case 'h':
                    mouse_hide ();
                    ShowState (Jailed, ++Invisible);
                    break;

#ifndef NO_JAIL
                case 'j':
                    if (Jailed) {
                        mouse_setbox (&full_box);
                        Jailed = false;
                    } else {
                        small_box.minx = max (info.pos.x - 10, full_box.minx);
                        small_box.miny = max (info.pos.y - 10, full_box.miny);
                        small_box.maxx = min (info.pos.x + 10, full_box.maxx);
                        small_box.maxy = min (info.pos.y + 10, full_box.maxy);
                        mouse_setbox (&small_box);
                        Jailed = true;
                    }
                    ShowState (Jailed, Invisible);
                    break;
#endif
                case 's':
                    mouse_show ();
                    if (Invisible) {
                        ShowState (Jailed, --Invisible);
                    }
                    break;

                case 'q':
                    Done = true;
                    break;

                default:
                    gotoxy (1, 9);
                    cprintf ("Spurious character: $%02X", C);
            }
        }
    } while (!Done);

#if DYN_DRV
    /* Uninstall and unload the driver. */
    CheckError ("mouse_unload", mouse_unload ());
#else
    /* Uninstall the static driver. */
    CheckError ("mouse_uninstall", mouse_uninstall ());
#endif

    /* Say goodbye */
    cputsxy (0, height / 2 + 3, "Goodbye!");
    return EXIT_SUCCESS;
}
示例#11
0
int main( void )
{

  int i = 0;
  int bufIndx;
  int bufPage;
  int charCnt;
  char cursorx;
  char cursory;


  memcpy ((void*) SPRITE0_DATA, MouseSprite, sizeof (MouseSprite));


  /* Load and install the mouse driver */
   mouse_load_driver (&mouse_def_callbacks, DRIVER);
/* Set the VIC sprite pointer */
    *(unsigned char*)SPRITE0_PTR = SPRITE0_DATA / 64;

    VIC.spr0_color = COLOR_WHITE;



  bgcolor (0);
  bordercolor (0);

  clrscr ();

  
  while( showAddrsBar()<1){bufPage=1;}

  bufPage=1;
  bufIndx=0;
  charCnt = screenRender(bufIndx);


  cursorx=20;
  cursory=11;

  mouse_show();
  mouse_move (cursorx , cursory);

  while( sRunning )
  {

    if( kbhit() )
    {
      //uint8_t pet = cgetc();
      char pet = cgetc();

      switch( pet )
      {
        //Move cursor down
        case PETSCII_DOWN:

          if(cursory < screenPixH){
            cursory++;
            mouse_move (cursorx , cursory);

          }
          break;

        //Move cursor up
        case PETSCII_UP:

          if(cursory > 0){
            cursory--;
            mouse_move (cursorx , cursory);

          }
          break;

        //Move cursor left
        case PETSCII_LEFT:

          if(cursorx > 0){
            cursorx--;
            mouse_move (cursorx , cursory);
          }
          break;

        //Move cursor right
        case PETSCII_RIGHT:

          if(cursorx < screenPixW-1){
            cursorx++;

            mouse_move (cursorx , cursory);
          }
          break;


        //Scroll UP
        case PETSCII_F1:

          bufIndx = bufIndx - charCnt;
          if(bufIndx <0){
            
            if(bufPage>1){
              getData();
              bufIndx=bufSize - charCnt;

              bufPage--;
              textcolor(bufPage);
            }
            else{bufIndx=0;}
          }
          charCnt = screenRender(bufIndx);
          break;

        //Scroll DOWN
        case PETSCII_F7:

          bufIndx = bufIndx + charCnt;
          if(bufIndx > bufSize){
            
            cbm_read( 2, sRecvBuf, sizeof(sRecvBuf));
            bufIndx=0;

            bufPage++;
            textcolor(bufPage);
          }
          charCnt = screenRender(bufIndx);
          break;

        //Show URL address entry bar
        case PETSCII_STOP:

          if(showAddrsBar() >0){
             bufPage=1;
             bufIndx=0;
             charCnt = screenRender(bufIndx);
          }
          break;

      }
    }

  }


  cbm_close( 2 );
  cbm_close( 7 );
  cbm_close( 8 );

  return(0);
}
示例#12
0
unsigned char screenRender( int indx )
{

  int i;
  int x;
  char tag_buf[7];
  char tag_href[] = "A HREF";


  i=indx;
  clrscr();
  bordercolor(6);
  while(wherey() < screenH && i<=bufSize){

    //i=0;
    if(sRecvBuf[i]=='<'){
      puts("***tag check***");
      //Place the html tag in the tab_buf string
      i++;
      for (x=0; x < 6; x++){
        tag_buf[x]=sRecvBuf[x+i];
      }
      tag_buf[x+1]='\0';

      puts(tag_buf);
      puts(tag_href);
      //Check for "href" tag
      if (strcmp(tag_href,tag_buf) == 0){
        puts("***href start***");
        i=i+9;
        linkTable[wherey()][2]=i;
        while(sRecvBuf[i++]!='"'){
          linkTable[wherey()][0]=wherex();
          pchar(sRecvBuf[i]);
        }
        linkTable[wherey()][3]=i;
        i+2;
        puts("***href end***");
        x=i;;
        //putchar( PETSCII_RVSON );//Turn on reverse
        while(sRecvBuf[i]!='<' && sRecvBuf[i+1]!='/'){
          //putchar(sRecvBuf[i++]);
          pchar(sRecvBuf[i++]);
        }
        //putchar( PETSCII_RVSOFF );//Turn off reverse

        linkTable[wherey()][1]=i-x;
        i=i+3;
      }
      else{

        while(sRecvBuf[i]!='>'){
          i++;
        }
        i++;

      }
    }
    //<a href="http://www.w3schools.com">Visit W3Schools.com!</a>

    pchar(sRecvBuf[i++]);
    //putchar(sRecvBuf[i++]);
    //cputc(sRecvBuf[i++]);
  }
  bordercolor(0);
  return(i - indx); 
}
示例#13
0
文件: conio.c 项目: jferreir/cc65
void main(void)
{
        int i, j, n;
        unsigned char xsize, ysize, tcol, bgcol, bcol, inpos = 0;

        clrscr();
        screensize(&xsize, &ysize);
        cputs("cc65 conio test\n\rInput: [        ]");

        cputsxy(0, 2, "Colors:" );
        tcol = textcolor(0); /* remember original textcolor */
        bgcol = bgcolor(0); /* remember original background color */
        bcol = bordercolor(0); /* remember original border color */
        bgcolor(bgcol);bordercolor(bcol);
        for (i = 0; i < 3; ++i) {
                gotoxy(i,3 + i);
                for (j = 0; j < 16; ++j) {
                        textcolor(j);
                        cputc('X');
                }
        }
        textcolor(tcol);

        cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize );

        chlinexy(0,6,xsize);
        cvlinexy(0,6,3);
        chlinexy(0,8,xsize);
        cvlinexy(xsize-1,6,3);
        cputcxy(0,6,CH_ULCORNER);
        cputcxy(xsize-1,6,CH_URCORNER);
        cputcxy(0,8,CH_LLCORNER);
        cputcxy(xsize-1,8,CH_LRCORNER);

        for (i = 0; i < 5; ++i) {
                gotoxy(xsize - 5,i);
                for (j = 0; j < 5; ++j) {
                        cputc(grid[i][j]);
                }
        }

        gotoxy(0,ysize - 2 - ((256 + xsize) / xsize));
        revers(1);
        for (i = 0; i < xsize; ++i) {
                cputc('0' + i % 10);
        }
        revers(0);
        for (i = 0; i < 256; ++i) {
            if ((i != '\n') && (i != '\r')) {
                    cputc(i);
            } else {
                    cputc(' ');
            }
        }
        while(wherex() > 0) {
                cputc('#');
        }
        revers(1);
        for (i = 0; i < xsize; ++i) {
                cputc('0' + i % 10);
        }
        revers(0);

        cursor(1);
        for(;;) {

                gotoxy(8, 2);
                j = n & 1;
                revers(j);
                cputc(j ? 'R' : ' ');
                revers(j ^ 1);
                cputs(" revers");
                revers(0);

                gotoxy(8 + inpos,1);
                i = cgetc();
                if ((i >= '0') && (i<='9')) {
                    textcolor(i - '0');
                } else if (i == CH_CURS_LEFT) {
                    inpos = (inpos - 1) & 7;
                } else if (i == CH_CURS_RIGHT) {
                    inpos = (inpos + 1) & 7;
                } else if (i == CH_F5) {
                    bgcol = (bgcol + 1) & 0x0f;
                    bordercolor(bgcol);
                } else if (i == CH_F6) {
                    bgcol = (bgcol - 1) & 0x0f;
                    bordercolor(bgcol);
                } else if (i == CH_F7) {
                    bgcol = (bgcol + 1) & 0x0f;
                    bgcolor(bgcol);
                } else if (i == CH_F8) {
                    bgcol = (bgcol - 1) & 0x0f;
                    bgcolor(bgcol);
                } else {
                    cputc(i);
                    inpos = (inpos + 1) & 7;
                }

                ++n;
        }

        for(;;);
}
示例#14
0
int main (void)
#endif
{
    struct mouse_info info;
    struct mouse_box full_box, small_box;
    unsigned char width, height;
    char C;
    bool Invisible = true, Done = false, Jailed = false;

    /* Initialize the debugger */
    DbgInit (0);

    /* Set dark-on-light colors.  Clear the screen. */
#ifdef __CBM__
    (void) bordercolor (COLOR_GRAY2);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_GRAY1);
#else
    (void) bordercolor (COLOR_BLUE);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_BLACK);
#endif
    cursor (0);
    clrscr ();

    /* If a lightpen driver is installed, then it can get a calibration value
    ** from this file (if it exists).  Or, the user can adjust the pen; and,
    ** the value will be put into this file, for the next time.
    ** (Other drivers will ignore this.)
    */
#if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
    pen_adjust ("pen.dat");
#endif

#if DYN_DRV
    /* If a dynamically loadable driver is named on the command line,
    ** then use that driver instead of the standard one.
    */
    if (argc > 1) {
        mouse_name = argv[1];
    } else {
        /* Output a warning about the standard driver that is needed. */
        DoWarning ();
        mouse_name = mouse_stddrv;
    }

    /* Load and install the driver. */
    CheckError ("mouse_load_driver",
                mouse_load_driver (&mouse_def_callbacks, mouse_name));
#else
    /* Install the driver. */
    CheckError ("mouse_install",
                mouse_install (&mouse_def_callbacks,
#  ifdef MOUSE_DRIVER
                               MOUSE_DRIVER
#  else
                               mouse_static_stddrv
#  endif
                               ));
#endif

    /* Get the initial bounding box. */
    mouse_getbox (&full_box);

    screensize (&width, &height);

top:
    clrscr ();

    /* Print a help line */
    cputs (" d)ebug  h)ide   q)uit   s)how   j)ail");

    /* Put a cross at the center of the screen. */
    gotoxy (width / 2 - 3, height / 2 - 1);
#if defined(__CBM__)
    cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#else
    cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#endif

    /* Test loop */
    ShowState (Jailed, Invisible);
    do {
        /* Get the current co-ordinates and button states; and, print them. */
        mouse_info (&info);
        gotoxy (0, 2);
        cprintf (" X  = %3d\r\n", info.pos.x);
        cprintf (" Y  = %3d\r\n", info.pos.y);
        cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');
        cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');

        /* Handle user input */
        if (kbhit ()) {
            cclearxy (1, 9, 23);
            switch (tolower (C = cgetc ())) {
                case 'd':
                    BREAK();

                    /* The debugger might have changed the colors.
                    ** Restore them.
                    */
#ifdef __CBM__
                    (void) bordercolor (COLOR_GRAY2);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_GRAY1);
#else
                    (void) bordercolor (COLOR_BLUE);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_BLACK);
#endif

                    /* The debugger changed the screen; restore it. */
                    goto top;

                case 'h':
                    mouse_hide ();
                    ShowState (Jailed, ++Invisible);
                    break;

                case 'j':
                    if (Jailed) {
                        mouse_setbox (&full_box);
                        Jailed = false;
                    } else {
                        small_box.minx = max (info.pos.x - 10, full_box.minx);
                        small_box.miny = max (info.pos.y - 10, full_box.miny);
                        small_box.maxx = min (info.pos.x + 10, full_box.maxx);
                        small_box.maxy = min (info.pos.y + 10, full_box.maxy);
                        mouse_setbox (&small_box);
                        Jailed = true;
                    }
                    ShowState (Jailed, Invisible);
                    break;

                case 's':
                    mouse_show ();
                    if (Invisible) {
                        ShowState (Jailed, --Invisible);
                    }
                    break;

                case 'q':
                    Done = true;
                    break;

                default:
                    gotoxy (1, 9);
                    cprintf ("Spurious character: $%02X", C);
            }
        }
    } while (!Done);

#if DYN_DRV
    /* Uninstall and unload the driver. */
    CheckError ("mouse_unload", mouse_unload ());
#else
    /* Uninstall the static driver. */
    CheckError ("mouse_uninstall", mouse_uninstall ());
#endif

    /* Say goodbye */
    cputsxy (0, height / 2 + 3, "Goodbye!");
    return EXIT_SUCCESS;
}