示例#1
0
文件: bbs-file.c 项目: kincki/contiki
int siFileExists(ST_FILE *pstFile)
{
   unsigned char ucBuff[128];
   unsigned char szTmp[15];
   unsigned char msg[40];
   unsigned char e, t, s;
   int siRet=0;

   strcpy(szTmp,"@:");
   strcat(szTmp, pstFile->szFileName);  
   strcat(szTmp, ",p,r");

   cbm_open( 15, pstFile->ucDeviceNo, 15, NULL);
   cbm_open( 2, pstFile->ucDeviceNo,  3, pstFile->szFileName);    

   if ( cbm_read(15, ucBuff, sizeof(ucBuff)) < 0) {
      return -1;
   }

   cbm_close(15);

   if (sscanf(ucBuff, "%hhu, %[^,], %hhu, %hhu", &e, msg, &t, &s) != 4) {
      puts("parse error");
      puts(ucBuff);
      return -1;
   }

   cbm_close(2);
   cbm_close(15);

   return (int) e;
}
示例#2
0
文件: bbs-file.c 项目: kincki/contiki
int ssReadRELFile(ST_FILE *pstFile, void *pvBuffer, unsigned int uiBuffSize, unsigned int uiRecNo)
{
  char command[40];
  char cbm_filename[40];
  int siRet=0;
  
  int channel, hi, lo;
  
  channel=3+96;

  sprintf(cbm_filename,"0:%s,l,%c", pstFile->szFileName, uiBuffSize);

  siRet = cbm_open( 15, pstFile->ucDeviceNo, 15, NULL);
  siRet = cbm_open( 2, pstFile->ucDeviceNo,  3, cbm_filename);    

  hi=(uiRecNo/256);
  lo=uiRecNo-(hi*256);
    
  sprintf(command, "p%c%c%c", channel, lo, hi);    
  siRet=cbm_write( 15, command, strlen(command));
  
  siRet = cbm_read( 2, pvBuffer, uiBuffSize);
  
  cbm_close(15);  
  cbm_close(2); 
       
  return siRet;
}
示例#3
0
文件: bbs-file.c 项目: kincki/contiki
int ssInitRELFile(ST_FILE *pstFile, void *pvBuffer, unsigned int uiBuffSize, unsigned int uiRecCount)
{
  char command[40];
  char cbm_filename[40];  
  int siRet=0;
  int siCount=0;
  
  int channel, hi, lo;
  
  channel=3+96;

  sprintf(cbm_filename,"0:%s,l,%c", pstFile->szFileName, uiBuffSize);
  
  siRet = cbm_open( 15, pstFile->ucDeviceNo, 15, NULL);
  siRet = cbm_open( 2, pstFile->ucDeviceNo,  3, cbm_filename);

  for (siCount = uiRecCount; siCount >= 1; siCount--)
  {
     hi=(siCount/256);
     lo=siCount-(hi*256);
    
     sprintf(command, "p%c%c%c", channel, lo, hi);    
     siRet=cbm_write( 15, command, strlen(command));
     siRet = cbm_write( 2, pvBuffer, uiBuffSize); 
  }

  cbm_close(15);  
  cbm_close(2);
  return siRet;	
}
示例#4
0
文件: bbs-file.c 项目: kincki/contiki
int siDriveStatus(ST_FILE *pstFile)
{
   unsigned char ucBuff[128];
   unsigned char msg[40];
   unsigned char e, t, s;


   if (cbm_open(1, pstFile->ucDeviceNo, 15, "") == 0) {
   
      if ( cbm_read(1, ucBuff, sizeof(ucBuff)) < 0) {
         return -1;
      }
      cbm_close(1);
   }

   if (sscanf(ucBuff, "%hhu, %[^,], %hhu, %hhu", &e, msg, &t, &s) != 4) {
      printf("\nparse error\n");
      puts(ucBuff);
      return -1;
   }

   /*printf("\n%hhu,%s,%hhu,%hhu\n", (int) e, msg, (int) t, (int) s);*/

   return (int) e;
}
示例#5
0
void
readfile(CBM_FILE f, unsigned char drv, const char * const filename)
{
    int n;

    n = cbm_open(f, drv, 2, filename, 0);
    printf("cbm_open \"%s\" %s!\n", filename, n == 0 ? "success" : "FAILED");

    if (n==0)
    {
        printf("File contents: '");
        cbm_talk(f, drv, 2);

        while (!cbm_get_eoi(f))
        {
            char c;

            cbm_raw_read(f, &c, 1);

            printf("%c", c);
        }
        printf("'\n");
        cbm_untalk(f);

        n = cbm_close(f, drv, 2);
        printf("cbm_close %s!\n", n == 0 ? "success" : "FAILED");
    }
    printf("\n");
}
示例#6
0
static void load_foo() {
    cbm_open(8, 8, 8, "foo");
    cbm_read(8, (char*)0x7ff, 0x801 + 0x1800);  // Low-code + music.
    cbm_read(8, HEAP_START, 0x1000);  // Code - throw it away...
    cbm_read(8, HEAP_START, (char*)0xd000u - HEAP_START);  // Animation!
    cbm_close(8);
}
示例#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
文件: print.c 项目: nnev/c128-kasse
void print_the_buffer(void) {
	BYTE c;
RETRY:
	c = cbm_open((BYTE)4, (BYTE)4, (BYTE)0, NULL);
	if (c != 0) {
		c128_perror(c, "cbm_open(printer)");
		if (retry_or_quit() == 'q')
			exit(1);

		goto RETRY;
	}
	c = cbm_write((BYTE)4, print_buffer, strlen(print_buffer));
	if (c != strlen(print_buffer)) {
		c128_perror(c, "write(printer)");
		if (retry_or_quit() == 'q')
			exit(1);
		goto RETRY;
	}
	cbm_close((BYTE)4);
	log_file(print_buffer);
}
示例#9
0
void
writefile(CBM_FILE f, unsigned char drv, const char * const filename)
{
    const char text[] = "Hello, just a simple Test!";

    int n;

    n = cbm_open(f, drv, 2, filename, 0);
    printf("cbm_open \"%s\" %s!\n", filename, n == 0 ? "success" : "FAILED");

    if (n == 0)
    {
        cbm_listen(f, drv, 2);
        cbm_raw_write(f, text, strlen(text));
        cbm_unlisten(f);

        n = cbm_close(f, drv, 2);
        printf("cbm_close %s!\n", n == 0 ? "success" : "FAILED");
    }

    printf("\n");
}
示例#10
0
文件: print.c 项目: nnev/c128-kasse
/*
 * Flushes the current log buffer to disk. Called either by log_file() when one
 * entire log file is completed or interactively.
 *
 */
void log_flush(void) {
	int c;
	static char filename[8];
	sprintf(filename, "log-%d", log_num);

	/* If we have written to this logfile before, we need to remove it first */
	if (log_heap_flushed > 0)
		_sysremove(filename);

	if ((c = cbm_open((BYTE)8, (BYTE)8, (BYTE)1, filename)) != 0) {
		c128_perror(c, "cbm_open(log)");
		exit(1);
	}
	c = cbm_write((BYTE)8, log_heap_buf, log_heap_offset);
	if (c != log_heap_offset) {
		textcolor(TC_LIGHT_RED);
		cprintf("\r\nCould not save logfile (wrote %d bytes, wanted %d bytes), please make sure the floppy is not full!\n", c, log_heap_offset);
		c128_perror(c, "cbm_write");
		exit(1);
	}
	cbm_close((BYTE)8);

	log_heap_flushed = log_heap_offset;
}
示例#11
0
/*---------------------------------------------------------------------------*/
static void
s_close(int f)
{
  cbm_close(f);
}
示例#12
0
文件: std.c 项目: Flaviowebit/openCBM
static void close_disk(void)
{
    cbm_close(fd_cbm, drive, 2);
}
示例#13
0
int ARCH_MAINDECL main(int argc, char *argv[])
{
    int status = 0, id_ofs = 0, name_len, i;
    CBM_FILE fd;
//    unsigned char drive, tracks = 35, bump = 1, orig = 0, show_progress = 0;
    unsigned char drive, tracks = 35, bump = 1, orig = 0x4b, show_progress = 0;
    char cmd[40], name[20], *arg;
    int erroroccured = 0;
    char *adapter = NULL;
    int option;

    struct option longopts[] =
    {
        { "help"       , no_argument      , NULL, 'h' },
        { "version"    , no_argument      , NULL, 'V' },
        { "adapter"    , required_argument, NULL, '@' },
        { "no-bump"    , no_argument      , NULL, 'n' },
        { "extended"   , no_argument      , NULL, 'x' },
//        { "original"   , no_argument      , NULL, 'o' },
{ "fill"  , required_argument, NULL, 'f' },

        { "status"     , no_argument      , NULL, 's' },
        { "progress"   , no_argument      , NULL, 'p' },

        /* undocumented */
        { "end-track"  , required_argument, NULL, 't' },
        { NULL         , 0                , NULL, 0   }
    };

//    const char shortopts[] ="hVnxospt:";
    const char shortopts[] ="hVnxf:spt:";


    while((option = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
    {
        switch(option)
        {
            case 'n': bump = 0;
                      break;
            case 'f': //orig = 0x4b;
orig=arch_atoc(optarg);
                      break;
            case 's': status = 1;
                      break;
            case 'x': tracks = 40;
                      break;
            case 'h': help();
                      return 0;
            case 'V': printf("frm_analyzer %s\n", OPENCBM_VERSION);
                      return 0;
            case 'p': show_progress = 1;
                      break;
            case 't': tracks = arch_atoc(optarg);
                      break;
            case '@': if (adapter == NULL)
                          adapter = cbmlibmisc_strdup(optarg);
                      else
                      {
                          fprintf(stderr, "--adapter/-@ given more than once.");
                          hint(argv[0]);
                          return 1;
                      }
                      break;
            default : hint(argv[0]);
                      return 1;
        }
    }

    if(optind + 2 != argc)
    {
        fprintf(stderr, "Usage: %s [OPTION]... DRIVE NAME,ID\n", argv[0]);
        hint(argv[0]);
        return 1;
    }

    arg = argv[optind++];
    drive = arch_atoc(arg);
    if(drive < 8 || drive > 11)
    {
        fprintf(stderr, "Invalid drive number (%s)\n", arg);
        return 1;
    }
    
    arg      = argv[optind++];
    name_len = 0;
    while(*arg)
    {
        unsigned char c;
        c = (unsigned char) toupper(*arg);
        if(c == ',')
        {
            if(id_ofs)
            {
                fprintf(stderr, "More than one `,' in disk name\n");
                return 1;
            }
            id_ofs = name_len;
        }
        name[name_len++] = c;
        if(name_len > 19)
        {
            fprintf(stderr, "Disk name too long\n");
            return 1;
        }
        arg++;
    }
    name[name_len] = 0;

    if(cbm_driver_open_ex(&fd, adapter) == 0)
    {
        cbm_upload(fd, drive, 0x0300, dskfrmt, sizeof(dskfrmt));
        sprintf(cmd, "M-E%c%c%c%c%c%c0:%s", 3, 3, tracks + 1, 
                orig, bump, show_progress, name);
        cbm_exec_command(fd, drive, cmd, 11+strlen(name));
#if 0
        if(show_progress)
        {
            /* do some handshake */
            cbm_iec_release(fd, IEC_CLOCK);
            for(i = 1; i <= tracks; i++)
            {
                cbm_iec_wait(fd, IEC_DATA, 1);
                cbm_iec_set(fd, IEC_CLOCK);
                cbm_iec_wait(fd, IEC_DATA, 0);
                cbm_iec_release(fd, IEC_CLOCK);

                printf("#");
                fflush(stdout);
            }
            printf("\n");
        }
#endif
        erroroccured = cbm_device_status(fd, drive, cmd, sizeof(cmd));

        if(erroroccured && status)
        {
            printf("%s\n", cmd);
        }

        if(!erroroccured && (tracks > 35))
        {
            cbm_open(fd, drive, 2, "#", 1);
            cbm_exec_command(fd, drive, "U1:2 0 18 0", 11);
            cbm_exec_command(fd, drive, "B-P2 192", 8);
            cbm_listen(fd, drive, 2);
            while(tracks > 35)
            {
                cbm_raw_write(fd, "\021\377\377\001", 4);
                tracks--;
            }
            cbm_unlisten(fd);
            cbm_exec_command(fd, drive, "U2:2 0 18 0", 11);
            cbm_close(fd, drive, 2);
        }

        if(!erroroccured && status)
        {
            cbm_device_status(fd, drive, cmd, sizeof(cmd));
            printf("%s\n", cmd);
        }
#if 1   // verbose output
        {
#if 0 // @TODO unused variables
            float RPMval;
            int sectors, virtGAPsze, remainder, trackTailGAP, flags, retry, lastTr;
            const char *vrfy;
#endif
            unsigned char data[0x100];
            if (cbm_download(fd, drive, 0x0500, data, sizeof(data)) == sizeof(data))
            {


#if 1
                // TODO, Pattern analyzer, get the lenght of the PLL synchronization period
                //
                    // search the last byte triple consisting of: 0x49, 0x24, 0x92
                    // 
                int k;
                const unsigned char pattern[]={0x49, 0x24, 0x92};
                // const unsigned char pattern[]={0xdb, 0x6d, 0xb6};

                for(k=sizeof(data)-3; k>=0; --k)
                {
                    if(data[k]==pattern[0] && data[k+1]==pattern[1] && data[k+2]==pattern[2]) break;
                }
                if(k<0)
                {
                    // no part of the written sequence was found
                    k=sizeof(data);
                }
                else
                {    
                        // now search the beginning of that "010010010010010010010010..." bit stream
                    while(k>=0 && data[k]==pattern[0] && data[k+1]==pattern[1] && data[k+2]==pattern[2])
                    {
                        k-=3;
                    }
                    k+=3;
    
                        // do single byte decreases
                    if(k>=1 && data[k-1]==pattern[2]) --k;
                    if(k>=1 && data[k-1]==pattern[1]) --k;
                    if(k>=1 && data[k-1]==pattern[0]) --k;
                }

                printf("Result with Pattern: 0x%02X / %3d, formatted on track %2d, PLL synchronization length: %3d\n", orig, orig, tracks, k);


                for (i=0; i < sizeof(data); i++)
                {
                    /*
                    if(data[i] == 0)
                    {
                        printf("\n");
                        break;
                    }
                    */
                    printf(" %02X", data[i]);
                    if((i&0x0f) == 0x0f) printf("\n");
                }
#else
                int i;
                printf("Track|Retry|sctrs|slctd|| GAP |modulo |modulo|tail| Verify  | RPM  |\n"
                       "     |     |     | GAP ||adjst|complmt| dvsr |GAP |         |      |\n"
                       "-----+-----+-----+-----++-----+-------+------+----+---------+------+\n");

                lastTr=-1;
                for (i=0; i < sizeof(data); i+=4)
                {
                    if(data[i]==0) break;    // no more data is available


                    if(data[i+3]>=0x40 && data[i]>42){
                            // logging continuation line
                        printf("     |     | debug log || $%02X | $%02X $%02X $%02X\n",
                               data[i], data[i+1], data[i+2], data[i+3]);
                        continue;    // proceed with next loop run
                        }


                    if(data[i]==lastTr) retry++;
                    else                retry=0;
                    lastTr=data[i];

                    if(data[i]>=25)            // preselect track dependent constants
                    {
                        if(data[i]>=31) sectors=17, RPMval=60000000.0f/16;
                        else            sectors=18, RPMval=60000000.0f/15;
                    }
                    else
                    {
                        if(data[i]>=18) sectors=19, RPMval=60000000.0f/14;
                        else            sectors=21, RPMval=60000000.0f/13;
                    }

                        // separate some flags
                    flags=(data[i+3]>>6)&0x03;
                    data[i+3]&=0x3f;

                    switch(flags)
                    {
                        case 0x01: vrfy="SYNC fail"; break;
                        case 0x02: vrfy="verify OK"; break;
                        case 0x03: vrfy="vrfy fail"; break;
                        default:   vrfy="   ./.   ";
                    }

                        // recalculation of the track tail GAP out of the
                        // choosen GAP for this track, the new GAP size
                        // adjustment and the complement of the remainder
                        // of the adjustment division

                    virtGAPsze=data[i+1]         -3;    // virtual GAP increase to
                        // prevent reformatting, when only one byte is missing


                    remainder=((data[i+2]==0xff) ? virtGAPsze : sectors)
                                 - data[i+3];


                    trackTailGAP=((data[i+2]==0xff) ? 0 : data[i+2]*sectors + virtGAPsze)
                                    + remainder;

                        // the following constants are nybble based (double the
                        // size of the well known constants for SYNC lengths,
                        // block header size, data block GAP and data block)
                        //
                        // (0x01&data[i+1]&sectors) is a correction term, if "half
                        // GAPs" are written and the number of sectors is odd
                        //
                    // RPMval / (sectors * (10+20+18+10 + 650 + data[i+1]) - (0x01&data[i+1]&sectors) + trackTailGAP - data[i+1])

                    RPMval = (flags != 0x01) ?
                        RPMval / (sectors * (10+20+18+10 + 650 + data[i+1]) - (0x01&data[i+1]&sectors) + trackTailGAP - data[i+1])
                        : 0;

                    printf(" %3u | ", data[i]);
                    if(retry>0) printf("%3u", retry);
                    else        printf("   ");
                   /*      " |sctrs |slctd  || GAP   |modulo   |modulo  |tail | Verify  | RPM  |\n"
                    *      " |      | GAP   ||adjst  |complmt  |        |GAP  |         |      |\n"
                    *      "-+----- +-----  ++-----  +-------  +------  +---- +---------+------+\n"
                    */
                    printf(" |  %2u | $%02X || $%02X |   $%02X |  $%02X |$%03X|%9s|%6.2f|\n",
                           sectors, data[i+1], data[i+2], data[i+3],
                           remainder, trackTailGAP, vrfy, RPMval);
                }
                printf("\n  *) Note: All GAP based numbers shown here (sedecimal values) are\n"
                         "           nybble based (4 GCR Bits) instead of GCR byte based.\n");
#endif
            }
            else
            {
示例#14
0
int main(int argc, char **argv)
{
    int ret, n;
    unsigned char drive = 8;
    CBM_FILE f;
    char buffer[80];
    char *devicetype_str;
    const char *drivername;
    enum cbm_device_type_e devicetype;
    int checklines = 0;
    int checkiohook = 0;

    if (argc>1)
    {
        int i;

        for (i=0; i < argc; i++)
        {
            switch (argv[i][0])
            {
            case '-':
                    checklines = 1;
                    break;

            case '+':
                    checkiohook = 1;
                    break;

            default:
                    drive = atoi(argv[i]);
            }
        }
    }

    printf("VDDTEST " __DATE__ " " __TIME__ ", using drive %u\n", drive);

    if (vdd_init())
    {
        printf("Could not initialize the VDD, aborting!\n");
        exit(1);
    }

    drivername = cbm_get_driver_name(0);
    printf("cbm_get_driver_name() returned %s.\n", drivername);

    ret = cbm_driver_open(&f, 0);

    if (ret)
    {
        printf("cbm_driver_open FAILED!\n");
        exit(1);
    }
    printf("cbm_driver_open success!\n\n");

    n = cbm_reset(f);
    printf("cbm_reset %s\n", n==0 ? "success" : "FAILED");

    if (checklines)
    {
        changelines(f);
    }

    n = cbm_device_status(f, drive, buffer, sizeof(buffer));
    printf("cbm_device_status returned: %u\n%s\n\n", n, buffer);

    n = cbm_open(f, drive, 15, "I0", 0);
    printf("cbm_open %u,15,\"I0\" %s!\n", drive, n == 0 ? "success" : "FAILED");
    n = cbm_close(f, drive, 15);
    printf("cbm_close %s!\n", n == 0 ? "success" : "FAILED");

    n = own_device_status(f, drive, buffer, sizeof(buffer));
    printf("own_device_status returned: %u\n%s\n\n", n, buffer);

    n = cbm_identify(f, drive, &devicetype, &devicetype_str);
    printf("cbm_identify %s!\n", n==0 ? "success" : "FAILED");
    printf("cbm_identify returned: %u - '%s'.\n\n", (unsigned int) devicetype,
                         devicetype_str);

    n = cbm_exec_command(f, drive, "S0:OPENCBM.VDD", 0);
    printf("cbm_exec_command(scratch) %s!\n", n==0 ? "success" : "FAILED");

    writefile(f, drive, "OPENCBM.VDD,S,W");
    readfile(f, drive, "OPENCBM.VDD,S,R");

    morse(f, drive);

    if (checkiohook)
    {
        unsigned int base = 0x0fc0;

        printf("trying to install iohook at 0x%08x ", base);
        if (vdd_install_iohook(f, base, 1))
        {
            int i;

            printf("success\n");

            for (i=0; i<15; i++)
            {
                outportb(base + 2, i);
                sleep(1);
            }

            printf("trying to uninstall iohook ");
            if (vdd_uninstall_iohook(f))
            {
                printf("success\n");
            }
            else
            {
                printf("FAILED\n");
            }
        }
        else
        {
            printf("FAILED\n");
        }
    }

    cbm_driver_close(f);
    printf("cbm_driver_close success!\n");

    return 0;
}
示例#15
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);
}
示例#16
0
int networkSetup(unsigned short drive)
{
   unsigned char  tmp[40];
   unsigned short cnt, ret;

   CTK_CFG_REC mycnf;

   memset(&mycnf, 0, sizeof(CTK_CFG_REC));
   do {
 
/*             1234567890123456789012345678901234567890   */
      printf("\n* BBS network Setup\n");

      printf("\nHost IP             : ");
      gets(tmp);
      nibbleIP(tmp, mycnf.srvip);

      printf("Netmask             : ");
      gets(tmp);
      nibbleIP(tmp, mycnf.netmask);

      printf("Gateway IP          : "); 
      gets(tmp);
      nibbleIP(tmp, mycnf.gateway);

      printf("DNS IP              : ");
      gets(tmp);
      nibbleIP(tmp, mycnf.nameserv);

      printf("Mem addr. ($de08)   : ");
      gets(tmp);
      sscanf(tmp, "%x", &mycnf.mem);

      printf("Driver (cs8900a.eth): ");
      gets(tmp);
      strcpy(mycnf.driver, tmp);

      printf("Write to drive # (8): ");
      gets(tmp);
      sscanf(tmp, "%d", &drive);

      printf("\nNetwork data correct (y/n)? ");

   } while (getchar() != 'y');

   strcpy(tmp, "@0:contiki.cfg,u,w");

   ret = cbm_open(2, drive, CBM_WRITE, tmp);

   if(! ret)
   {
        for(cnt = 0; cnt <= 3; cnt++)
           cbm_write(2, &mycnf.srvip[cnt], sizeof(unsigned char));

        for(cnt = 0; cnt <= 3; cnt++)
           cbm_write(2, &mycnf.netmask[cnt], sizeof(unsigned char));

        for(cnt = 0; cnt <= 3; cnt++) 
          cbm_write(2, &mycnf.gateway[cnt], sizeof(unsigned char));

        for(cnt = 0; cnt <= 3; cnt++)
           cbm_write(2, &mycnf.nameserv[cnt], sizeof(unsigned char));

        cbm_write(2, &mycnf.mem, sizeof(&mycnf.mem));

        cbm_write(2, mycnf.driver, sizeof(mycnf.driver));

   } else {

      printf("\n\r**error - can't write file: 'contiki.cfg'");      
   }

   cbm_close(2);
   
   return ret;
}