Example #1
0
/*
** There is a delay between when the VIC sends its signal, and when the display
** shows that signal.  There is another delay between the display and when
** the lightpen says that it saw that signal. Each display and pen is different.
** Therefore, the driver must be calibrated to them.  A white bar is painted on
** the screen; and, a line is drawn down the middle of it.  When the user clicks
** on that line, the difference between its position and where the VIC thinks
** that the pen is pointing becomes an offset that is subtracted from what the
** VIC sees.
*/
void __fastcall__ pen_calibrate (unsigned char *XOffset)
{
    unsigned char oldBg = bgcolor (COLOR_BLUE);
    unsigned char oldText = textcolor (COLOR_GRAY3);
    unsigned char oldRev = revers (1);
    unsigned char sprite0Color = VIC.spr_color[0];
    unsigned char width, width2, height, height4, height8;
    struct mouse_info info;

    screensize (&width, &height);
    width2 = width / 2;
    height4 = height / 4;
    height8 = height4 * 8;

    /* Draw a bar and line. */

    clrscr ();
    cclearxy (0, height4, height4 * width);
    cvlinexy (width2, height4 + 1, height4 - 2);
    revers (0);

    /* Print instructions. */

    cputsxy (width2 - (sizeof COMMAND1) / 2, height / 2 + 1, COMMAND1);
    cputsxy (width2 - (sizeof COMMAND2) / 2, height / 2 + 3, COMMAND2);

    VIC.spr_color[0] = COLOR_GRAY2;
    mouse_show ();
    mouse_move (width2 * 8, height8 / 2);

    for (;;) {
        /* Wait for the main button to be released. */

        do ; while ((mouse_buttons () & MOUSE_BTN_LEFT));

        /* Wait for the main button to be pressed. */

        do {
            mouse_info (&info);
        } while (!(info.buttons & MOUSE_BTN_LEFT));

        /* Find out if the pen is on or off the bar. */

        if (info.pos.y < height8 || info.pos.y >= height8 * 2) {
            break;
        }

        /* On the bar; adjust the offset. */
        /* Characters are eight pixels wide.
        ** The VIC-II sees every other pixel;
        ** so, we use half of the difference.
        */

        *XOffset += (info.pos.x - (width2 * 8 + 8/2)) / 2;
    }

    /* Off the bar; wait for the main button to be released. */

    do ; while ((mouse_buttons () & MOUSE_BTN_LEFT));

    mouse_hide ();
    VIC.spr_color[0] = sprite0Color;
    revers (oldRev);
    textcolor (oldText);
    bgcolor (oldBg);
    clrscr ();
}
Example #2
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);
}
Example #3
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;

#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;
}
Example #4
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;
}