public int read1(){
    int ret;
    if(endbyte>=storage){
      ret=-1;
      endbit++;
      if(endbit>7){
        endbit=0;
        ptr++;
        endbyte++;
      }
      return (ret);
    }

    ret=(buffer[ptr]>>endbit)&1;

    endbit++;
    if(endbit>7){
      endbit=0;
      ptr++;
      endbyte++;
    }
    return (ret);
  }