Ejemplo n.º 1
0
static void rfc822(FILE *fp, struct fetchinfo *fi,
	struct imapscaninfo *info, unsigned long msgnum,
	struct rfc2045 *rfcp)
{
unsigned long n=0;
int	c;
char	buf[BUFSIZ];
unsigned long i;

	writes("RFC822 ");

	if (fseek(fp, 0L, SEEK_SET) == -1)
	{
		fetcherror("fseek", fi, info, msgnum);
		writes("{0}\r\n");
		return;
	}
	while ((c=getc(fp)) != EOF)
	{
		++n;
		if (c == '\n')	++n;
	}

	if (fseek(fp, 0L, SEEK_SET) == -1)
	{
		fetcherror("fseek", fi, info, msgnum);
		writes("{0}\r\n");
		return;
	}
	writes("{");
	writen(n);
	writes("}\r\n");

	i=0;
	while (n)
	{
		c=getc(fp);
		if (c == '\n')
		{
			if (i >= sizeof(buf))
			{
				writemem(buf, i);
				i=0;
			}
			buf[i++]='\r';
			if (--n == 0)	break;
		}

		if (i >= sizeof(buf))
		{
			writemem(buf, i);
			i=0;
		}
		buf[i++]=c;
		--n;
		++body_count;
	}
	writemem(buf, i);
}
Ejemplo n.º 2
0
static void rfc822text(FILE *fp, struct fetchinfo *fi,
	struct imapscaninfo *info, unsigned long msgnum,
	struct rfc2045 *rfcp)
{
off_t start_pos, end_pos, start_body;
off_t nlines, nbodylines;
unsigned long i;
int	c;
char	buf[BUFSIZ];
unsigned long l;

	writes("RFC822.TEXT {");

	rfc2045_mimepos(rfcp, &start_pos, &end_pos, &start_body,
		&nlines, &nbodylines);

	if (fseek(fp, start_body, SEEK_SET) == -1)
	{
		fetcherror("fseek", fi, info, msgnum);
		writes("0}\r\n");
		return;
	}

	i=end_pos - start_body + nbodylines;

	writen(i);
	writes("}\r\n");

	l=0;
	while (i)
	{
		c=getc(fp);
		if (c == EOF)
		{
			fetcherror("unexpected EOF", fi, info, msgnum);
			_exit(1);
		}
		--i;
		if (l >= sizeof(BUFSIZ))
		{
			writemem(buf, l);
			l=0;
		}
		if (c == '\n' && i)
		{
			--i;
			buf[l++]='\r';
			if (l >= sizeof(BUFSIZ))
			{
				writemem(buf, l);
				l=0;
			}
		}
		buf[l++]=c;
		++body_count;
	}
	writemem(buf, l);
}
Ejemplo n.º 3
0
void writeqs(const char *s)
{
size_t	i=strlen(s), j;

	while (i)
	{
		for (j=0; j<i; j++)
		{
			if ( s[j] == '"' || s[j] == '\\')
			{
				writemem(s, j);
				writemem("\\", 1);
				writemem(s+j, 1);
				++j;
				s += j;
				i -= j;
				j=0;
				break;
			}
#if 0
			if (s[j] == '&')
			{
				writemem(s, j);
				writemem("&-", 2);
				++j;
				s += j;
				i -= j;
				j=0;
				break;
			}

			if (s[j] < ' ' || s[j] >= 0x7F)
			{
			char	*q;

				writemem(s, j);
				++j;
				s += j;
				i -= j;
				for (j=0; j<i; j++)
					if (s[j] >= ' ' && s[j] < 0x7F)
						break;
				q=imap_utf7_encode(s, j);
				if (!q)	write_error_exit(0);
				writemem("&", 1);
				writes(q);
				writemem("-", 1);
				s += j;
				i -= j;
				j=0;
				break;
			}
#endif
		}
		writemem(s, j);
		s += j;
		i -= j;
	}
}
Ejemplo n.º 4
0
void writen(unsigned long n)
{
char	buf[40];

	sprintf(buf, "%lu", n);
	writemem(buf, strlen(buf));
}
Ejemplo n.º 5
0
static int
cmd_writemem_run( chain_t *chain, char *params[] )
{
	uint32_t adr;
	uint32_t len;
	FILE *f;

	if (cmd_params( params ) != 4)
		return -1;

	if (!bus) {
		printf( _("Error: Bus driver missing.\n") );
		return 1;
	}

	if (cmd_get_number( params[1], &adr) || cmd_get_number( params[2], &len))
		return -1;

	f = fopen( params[3], "r" );
	if (!f) {
		printf( _("Unable to open file `%s'!\n"), params[3] );
		return 1;
	}
	writemem( bus, f, adr, len );
	fclose( f );

	return 1;
}
Ejemplo n.º 6
0
void L3G4200D::init( int scale) {
//From  Jim Lindblom of Sparkfun's code

   _dev_address = L3G4200D_Address;

  // Enable x, y, z and turn off power down:
  writemem(CTRL_REG1, 0b00001111);

  // If you'd like to adjust/use the HPF, you can edit the line below to configure CTRL_REG2:
  writemem(CTRL_REG2, 0b00000000);

  // Configure CTRL_REG3 to generate data ready interrupt on INT2
  // No interrupts used on INT1, if you'd like to configure INT1
  // or INT2 otherwise, consult the datasheet:
  writemem(CTRL_REG3, 0b00001000);

  // CTRL_REG4 controls the full-scale range, among other things:

  if(scale == 250){
    writemem(CTRL_REG4, 0b00000000);
  }else if(scale == 500){
    writemem(CTRL_REG4, 0b00010000);
  }else{
    writemem(CTRL_REG4, 0b00110000);
  }

  // CTRL_REG5 controls high-pass filtering of outputs, use it
  // if you'd like:
  writemem(CTRL_REG5, 0b00000000);
}
Ejemplo n.º 7
0
BOOL cwindow::emptyscreen()
{             
	int		i;
	
	for(i = 1; i <= m_nmaxrows; i ++)   
		writemem(m_npage, i + m_nrow1, 0 + m_ncol1, '\0', (m_nmaxcols - 0) * 2);

	m_nwritedrow = 1;
	m_nactiverow = 1;

	return TRUE;
}
Ejemplo n.º 8
0
static void printheader(struct fetchheaderinfo *fi, const char *p, size_t s)
{
	size_t i;

	if (fi->skipping)
	{
		if (fi->skipping > s)
		{
			fi->skipping -= s;
			return;
		}
		p += fi->skipping;
		s -= fi->skipping;
		fi->skipping=0;
	}
	if (s > fi->cnt)	s=fi->cnt;
	for (i=0; i <= s; i++)
		if (p[i] != '\r')
			++header_count;
	writemem(p, s);
	fi->cnt -= s;
}
Ejemplo n.º 9
0
void ITG3200::setZgyroStandby(bool _Status) {
  readmem(PWR_MGM, 1, &_buff[0]);
  writemem(PWR_MGM, ((_buff[0] & PWRMGM_STBY_ZG) | _Status << 3));
}
Ejemplo n.º 10
0
void ITG3200::reset() {     
  writemem(PWR_MGM, PWRMGM_HRESET); 
  delay(GYROSTART_UP_DELAY); //gyro startup 
}
Ejemplo n.º 11
0
void ITG3200::setPowerMode(bool _State) {
  readmem(PWR_MGM, 1, &_buff[0]);
  writemem(PWR_MGM, ((_buff[0] & ~PWRMGM_SLEEP) | _State << 6));  
}
Ejemplo n.º 12
0
int main(int argc, const char** argv)
{

  while(running)
  {
    //fetch
    int op = readmem(pc);
    pc++;
    
    //decode
    int op_id = op >> 9;
    int x = (op >> 6) & 7; //shift by 6, and take 3 bits (2^3-1 = 7)
                            //x & 0b000000111 (masking)
                            //0x -> hex
                            //0x0005_1234 <- nice formating
    
	int y = (op >> 3) & 7;	//bits 5 to 3
    int z = (op >> 0) & 7;	//bits 2 to 0
    int imm = (op >> 0) & 63; //bits 5 to 0

    switch(op_id)
    {
      case op_nop: //do nothing
        
        break;
        
      case op_add: //   x <- y + z
        reg[x] = reg[y] + reg[z];
        break;

      case op_shift: // x <- y << z
      reg[x] = reg[y] << reg[z];
        break;
      
      case op_xor: //   x <- y ^ z
        reg[x] = reg[y] ^ reg[z];
        break;
        
      case op_read: //  x <- readmem(y)
        if ( z !=0 )
          put("ERROR");
        else
          reg[x] = readmem(reg[y]);
        break;
      
      case op_write: // writemem(y,x)
        if ( z !=0 )
          put("ERROR");
        else
          writemem(reg[y],reg[x]);
        break;      
      
      case op_print: //printf("%d",r[x])
        if ( y !=0 || z !=0 )
          put("ERROR");
        else
          printf("%d",reg[x]);
        break;

	case op_put: // putc(x)
        if ( y !=0 || z !=0 )
          put("ERROR");
        else
          put(reg[x]);
        break;

	  case op_mov:
		  reg[x] = imm;
		  break;
    }
  }
}
Ejemplo n.º 13
0
void ITG3200::setRawDataReady(bool _State) {
  readmem(INT_CFG, 1, &_buff[0]);
  writemem(INT_CFG, ((_buff[0] & ~INTCFG_RAW_RDY_EN) | _State)); 
}
Ejemplo n.º 14
0
void ITG3200::setSampleRateDiv(byte _SampleRate) {
  writemem(SMPLRT_DIV, _SampleRate);
}
int main(int argc, char *argv[])
{


  if(argc != 2) { printf("Not correct argumento\n"); return 1; }
  
  // sig is easy to find: 
  // first search for youtube.com in friendsui
  // next, go to the array it's referenced in
  // lastly click the xref of the array!
  // the start of the function is what this sig is!
  const char *sig = "\x55"
  "\x57"
  "\x56"
  "\x53"
  "\x83\xEC?"
  "\xE8????"
  "\x81?????"
  "\x8B???"
  "\x8D?????"
  "\x8D?????"
  "\xEB?"
  "\x83\xC6\x04";

  pid_t pid;

  sscanf(argv[1], "%d", &pid);
  
  
  char temp[256];
  snprintf(temp, 256, "/proc/%i/mem", pid);
  FILE *f = fopen(temp, "rb+");

  char mem[1];

  const char *now = sig;

  memory mems;
  int skip = 0;

  while(GetMemory(&mems, argv[1], "friendsui.so",skip))
  {

    printf("%08lX - %08lX\n", mems.start, mems.end);

    for(long i = mems.start; i < mems.end; i++)
    {

      if(!readmem(f, i, (void *)mem, 1))
      {
        printf("END!! :(: %08lX\n", i);
        break;
      }

      if(*now == '?' || *now == mem[0])
      {
        now++;
        if(!*now) // end of sig
        {
          long write = i - strlen(sig) + 1;

          // mov eax, 1 
          // retn
          if(!writemem(f, write, (void *)"\xB8\x01\x00\x00\x00\xC3", 6))
          {
            printf("NO WRITE!!\n");
          }
          printf("Found!!! %08lX\n", i);
          break;
        }
      }
      else
        now = sig;
    }
    skip++;
  }
  fclose(f);
  printf("Done!\n");


  return 0;
}
Ejemplo n.º 16
0
static void dofetchheadersbuf(FILE *fp, struct fetchinfo *fi,
	struct imapscaninfo *info, unsigned long msgnum,
	struct rfc2045 *mimep,
	int (*headerfunc)(struct fetchinfo *fi, const char *))
{
off_t start_pos, end_pos, start_body;
off_t nlines, nbodylines;
size_t i,j,k,l;
char	buf[BUFSIZ+2];
int	goodheader;
unsigned long skipping;
unsigned long cnt;
char	*p;
int	ii;

	rfc2045_mimepos(mimep, &start_pos, &end_pos, &start_body,
		&nlines, &nbodylines);
	if (fseek(fp, start_pos, SEEK_SET) == -1)
	{
		writes("{0}\r\n");
		fetcherror("fseek", fi, info, msgnum);
		return;
	}

	ii=fread(buf, 1, start_body - start_pos, fp);
	if (ii < 0 || (i=ii) != start_body - start_pos)
	{
		fetcherror("unexpected EOF", fi, info, msgnum);
		exit(1);
	}
	goodheader= (*headerfunc)(fi, "");

	l=0;
	for (j=0; j<i; )
	{
		if (buf[j] != '\n' && buf[j] != '\r' &&
			!isspace((int)(unsigned char)buf[j]))
		{
			goodheader= (*headerfunc)(fi, "");

			for (k=j; k<i; k++)
			{
				if (buf[k] == '\n' || buf[k] == ':')
					break;
			}

			if (k < i && buf[k] == ':')
			{
				buf[k]=0;
				goodheader=(*headerfunc)(fi, buf+j);
				buf[k]=':';
			}
		}
		else if (buf[j] == '\n')
			goodheader=0;

		for (k=j; k<i; k++)
			if (buf[k] == '\n')
			{
				++k;
				break;
			}

		if (goodheader)
		{
			while (j<k)
				buf[l++]=buf[j++];
		}
		j=k;
	}

	buf[l++]='\n';	/* Always append a blank line */

	cnt=l;
	for (i=0; i<l; i++)
		if (buf[i] == '\n')	++cnt;

	skipping=0;
	if (fi->ispartial)
	{
		skipping=fi->partialstart;
		if (skipping > cnt)	skipping=cnt;
		cnt -= skipping;
		if (fi->ispartial > 1 && cnt > fi->partialend)
			cnt=fi->partialend;
	}

	writes("{");
	writen(cnt);
	writes("}\r\n");
	p=buf;
	while (skipping)
	{
		if (*p == '\n')
		{
			--skipping;
			if (skipping == 0)
			{
				if (cnt)
				{
					writes("\n");
					--cnt;
				}
				break;
			}
		}
		--skipping;
		++p;
	}

	while (cnt)
	{
		if (*p == '\n')
		{
			writes("\r");
			if (--cnt == 0)	break;
			writes("\n");
			--cnt;
			++p;
			continue;
		}
		for (i=0; i<cnt; i++)
			if (p[i] == '\n')
				break;
		writemem(p, i);
		p += i;
		cnt -= i;
		header_count += i;
	}
}
Ejemplo n.º 17
0
void ITG3200::setINTDriveType(bool _State) {
  readmem(INT_CFG, 1, &_buff[0]);
  writemem(INT_CFG, ((_buff[0] & ~INTCFG_OPEN) | _State << 6)); 
}
Ejemplo n.º 18
0
void debugger_do()
{
        int c, d, e, f;
        int params;
        uint8_t temp;
        char outs[256];
        char ins[256];
        if (!opcode)
        {
                sprintf(outs, "BRK %04X! %04X %04X\n", pc, oldpc, oldoldpc);
                debug_out(outs);
        }
        if (!opcode) debug = 1;

        for (c = 0; c < 8; c++)
        {
                if (breakpoints[c] == pc)
                {
                        debug = 1;
                        sprintf(outs, "    Break at %04X\n", pc);
                        debug_out(outs);
                }
        }
        if (!debug) return;
//        if (!opcode) printf("BRK at %04X\n",pc);
        if (debugstep)
        {
                debugstep--;
                if (debugstep) return;
        }
        indebug = 1;
        while (1)
        {
                d = debug_disaddr;
                debug_disaddr = pc;
                debug_disassemble();
                debug_disaddr = d;
                sprintf(outs, "  >");
                debug_out(outs);
#ifdef WIN32
                c = ReadConsoleA(cinf, ins, 255, (LPDWORD)&d, NULL);
                ins[d] = 0;
#else
                d = (int)fgets(ins, 255, stdin);
#endif
                d = 0;
                while (ins[d] != 32 && ins[d] != 0xA && ins[d] != 0xD && ins[d] != 0) d++;
                while (ins[d] == 32) d++;
                if (ins[d] == 0xA || ins[d] == 0xD || ins[d] == 0) params = 0;
                else                                               params = 1;

                if (ins[0] == 0xA || ins[0] == 0xD) ins[0] = debug_lastcommand;
//debug_out("Processing!\n");
                switch (ins[0])
                {
                        case 'c': case 'C':
                        debug = 0;
                        indebug = 0;
                        return;
                        case 'm': case 'M':
                        if (params) sscanf(&ins[d], "%X", (unsigned int *)&debug_memaddr);
                        for (c = 0; c < 16; c++)
                        {
                                sprintf(outs, "    %04X : ", debug_memaddr);
                                debug_out(outs);
                                for (d = 0; d < 16; d++)
                                {
                                        sprintf(outs, "%02X ", debug_readmem(debug_memaddr + d));
                                        debug_out(outs);
                                }
                                debug_out("  ");
                                for (d = 0; d < 16; d++)
                                {
                                        temp = debug_readmem(debug_memaddr + d);
                                        if (temp < 32) sprintf(outs, ".");
                                        else           sprintf(outs, "%c", temp);
                                        debug_out(outs);
                                }
                                debug_memaddr += 16;
                                debug_out("\n");
                        }
                        break;
                        case 'd': case 'D':
                        if (params) sscanf(&ins[d], "%X", (unsigned int *)&debug_disaddr);
                        for (c = 0; c < 12; c++)
                        {
                                debug_out("    ");
                                debug_disassemble();
                                debug_out("\n");
                        }
                        break;
                        case 'r': case 'R':
                        if (params)
                        {
                                if (!strncasecmp(&ins[d], "sysvia", 6))
                                {
                                        sprintf(outs, "    System VIA registers :\n");
                                        debug_out(outs);
                                        sprintf(outs, "    ORA  %02X ORB  %02X IRA %02X IRB %02X\n", sysvia.ora,  sysvia.orb,  sysvia.ira, sysvia.irb);
                                        debug_out(outs);
                                        sprintf(outs, "    DDRA %02X DDRB %02X ACR %02X PCR %02X\n", sysvia.ddra, sysvia.ddrb, sysvia.acr, sysvia.pcr);
                                        debug_out(outs);
                                        sprintf(outs, "    Timer 1 latch %04X   count %04X\n", sysvia.t1l / 2, (sysvia.t1c / 2) & 0xFFFF);
                                        debug_out(outs);
                                        sprintf(outs, "    Timer 2 latch %04X   count %04X\n", sysvia.t2l / 2, (sysvia.t2c / 2) & 0xFFFF);
                                        debug_out(outs);
                                        sprintf(outs, "    IER %02X IFR %02X\n", sysvia.ier, sysvia.ifr);
                                        debug_out(outs);
                                }
                                if (!strncasecmp(&ins[d], "uservia", 7))
                                {
                                        sprintf(outs, "    User VIA registers :\n");
                                        debug_out(outs);
                                        sprintf(outs, "    ORA  %02X ORB  %02X IRA %02X IRB %02X\n", uservia.ora,  uservia.orb,  uservia.ira, uservia.irb);
                                        debug_out(outs);
                                        sprintf(outs, "    DDRA %02X DDRB %02X ACR %02X PCR %02X\n", uservia.ddra, uservia.ddrb, uservia.acr, uservia.pcr);
                                        debug_out(outs);
                                        sprintf(outs, "    Timer 1 latch %04X   count %04X\n", uservia.t1l / 2, (uservia.t1c / 2) & 0xFFFF);
                                        debug_out(outs);
                                        sprintf(outs, "    Timer 2 latch %04X   count %04X\n", uservia.t2l / 2, (uservia.t2c / 2) & 0xFFFF);
                                        debug_out(outs);
                                        sprintf(outs, "    IER %02X IFR %02X\n", uservia.ier, uservia.ifr);
                                        debug_out(outs);
                                }
                                if (!strncasecmp(&ins[d], "crtc", 4))
                                {
                                        sprintf(outs, "    CRTC registers :\n");
                                        debug_out(outs);
                                        sprintf(outs, "    Index=%i\n", crtc_i);
                                        debug_out(outs);
                                        sprintf(outs, "    R0 =%02X  R1 =%02X  R2 =%02X  R3 =%02X  R4 =%02X  R5 =%02X  R6 =%02X  R7 =%02X  R8 =%02X\n", crtc[0], crtc[1],  crtc[2],  crtc[3],  crtc[4],  crtc[5],  crtc[6],  crtc[7],  crtc[8]);
                                        debug_out(outs);
                                        sprintf(outs, "    R9 =%02X  R10=%02X  R11=%02X  R12=%02X  R13=%02X  R14=%02X  R15=%02X  R16=%02X  R17=%02X\n", crtc[9], crtc[10], crtc[11], crtc[12], crtc[13], crtc[14], crtc[15], crtc[16], crtc[17]);
                                        debug_out(outs);
                                        sprintf(outs, "    VC=%i SC=%i HC=%i MA=%04X\n", vc, sc, hc, ma);
                                        debug_out(outs);
                                }
                                if (!strncasecmp(&ins[d],"vidproc",7))
                                {
                                        sprintf(outs, "    VIDPROC registers :\n");
                                        debug_out(outs);
                                        sprintf(outs, "    Control=%02X\n", ula_ctrl);
                                        debug_out(outs);
                                        sprintf(outs, "    Palette entries :\n");
                                        debug_out(outs);
                                        sprintf(outs, "     0=%01X   1=%01X   2=%01X   3=%01X   4=%01X   5=%01X   6=%01X   7=%01X\n", ula_palbak[0], ula_palbak[1], ula_palbak[2],  ula_palbak[3],  ula_palbak[4],  ula_palbak[5],  ula_palbak[6],  ula_palbak[7]);
                                        debug_out(outs);
                                        sprintf(outs, "     8=%01X   9=%01X  10=%01X  11=%01X  12=%01X  13=%01X  14=%01X  15=%01X\n", ula_palbak[8], ula_palbak[9], ula_palbak[10], ula_palbak[11], ula_palbak[12], ula_palbak[13], ula_palbak[14], ula_palbak[15]);
                                        debug_out(outs);
                                }
                                if (!strncasecmp(&ins[d],"sound",5))
                                {
                                        sprintf(outs, "    Sound registers :\n");
                                        debug_out(outs);
                                        sprintf(outs, "    Voice 0 frequency = %04X   volume = %i  control = %02X\n", sn_latch[0] >> 6, sn_vol[0], sn_noise);
                                        debug_out(outs);
                                        sprintf(outs, "    Voice 1 frequency = %04X   volume = %i\n", sn_latch[1] >> 6, sn_vol[1]);
                                        debug_out(outs);
                                        sprintf(outs, "    Voice 2 frequency = %04X   volume = %i\n", sn_latch[2] >> 6, sn_vol[2]);
                                        debug_out(outs);
                                        sprintf(outs, "    Voice 3 frequency = %04X   volume = %i\n", sn_latch[3] >> 6, sn_vol[3]);
                                        debug_out(outs);
                                }
                        }
                        else
                        {
                                sprintf(outs, "    6502 registers :\n");
                                debug_out(outs);
                                sprintf(outs, "    A=%02X X=%02X Y=%02X S=01%02X PC=%04X\n", a, x, y, s, pc);
                                debug_out(outs);
                                sprintf(outs, "    Status : %c%c%c%c%c%c\n", (p.n) ? 'N' : ' ', (p.v) ? 'V' : ' ', (p.d) ? 'D' : ' ', (p.i) ? 'I' : ' ', (p.z) ? 'Z' : ' ', (p.c) ? 'C' : ' ');
                                debug_out(outs);
                        }
                        break;
                        case 's': case 'S':
                        if (params) sscanf(&ins[d], "%i", &debugstep);
                        else        debugstep = 1;
                        debug_lastcommand = ins[0];
                        indebug = 0;
                        return;
                        case 'b': case 'B':
                        if (!strncasecmp(ins, "breakr", 6))
                        {
                                if (!params) break;
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakpoints[c] == -1)
                                        {
                                                sscanf(&ins[d], "%X", &breakr[c]);
                                                sprintf(outs, "    Read breakpoint %i set to %04X\n", c, breakr[c]);
                                                debug_out(outs);
                                                break;
                                        }
                                }
                        }
                        else if (!strncasecmp(ins, "breakw", 6))
                        {
                                if (!params) break;
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakpoints[c] == -1)
                                        {
                                                sscanf(&ins[d], "%X", &breakw[c]);
                                                sprintf(outs, "    Write breakpoint %i set to %04X\n", c, breakw[c]);
                                                debug_out(outs);
                                                break;
                                        }
                                }
                        }
                        else if (!strncasecmp(ins, "break", 5))
                        {
                                if (!params) break;
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakpoints[c] == -1)
                                        {
                                                sscanf(&ins[d], "%X", &breakpoints[c]);
                                                sprintf(outs, "    Breakpoint %i set to %04X\n", c, breakpoints[c]);
                                                debug_out(outs);
                                                break;
                                        }
                                }
                        }
                        if (!strncasecmp(ins, "blist", 5))
                        {
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakpoints[c] != -1)
                                        {
                                                sprintf(outs, "    Breakpoint %i : %04X\n", c, breakpoints[c]);
                                                debug_out(outs);
                                        }
                                }
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakr[c] != -1)
                                        {
                                                sprintf(outs, "    Read breakpoint %i : %04X\n", c, breakr[c]);
                                                debug_out(outs);
                                        }
                                }
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakw[c] != -1)
                                        {
                                                sprintf(outs, "    Write breakpoint %i : %04X\n", c, breakw[c]);
                                                debug_out(outs);
                                        }
                                }
                        }
                        if (!strncasecmp(ins, "bclearr", 7))
                        {
                                if (!params) break;
                                sscanf(&ins[d], "%X", &e);
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakr[c] == e) breakr[c] = -1;
                                        if (c == e) breakr[c] = -1;
                                }
                        }
                        else if (!strncasecmp(ins, "bclearw", 7))
                        {
                                if (!params) break;
                                sscanf(&ins[d], "%X", &e);
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakw[c] == e) breakw[c] = -1;
                                        if (c == e) breakw[c] = -1;
                                }
                        }
                        else if (!strncasecmp(ins, "bclear", 6))
                        {
                                if (!params) break;
                                sscanf(&ins[d], "%X", &e);
                                for (c = 0; c < 8; c++)
                                {
                                        if (breakpoints[c] == e) breakpoints[c] = -1;
                                        if (c == e) breakpoints[c] = -1;
                                }
                        }
                        break;
                        case 'w': case 'W':
                        if (!strncasecmp(ins, "watchr", 6))
                        {
                                if (!params) break;
                                for (c = 0; c < 8; c++)
                                {
                                        if (watchr[c] == -1)
                                        {
                                                sscanf(&ins[d], "%X", &watchr[c]);
                                                sprintf(outs, "    Read watchpoint %i set to %04X\n", c, watchr[c]);
                                                debug_out(outs);
                                                break;
                                        }
                                }
                                break;
                        }
                        if (!strncasecmp(ins, "watchw", 6))
                        {
                                if (!params) break;
                                for (c = 0; c < 8; c++)
                                {
                                        if (watchw[c] == -1)
                                        {
                                                sscanf(&ins[d], "%X", &watchw[c]);
                                                sprintf(outs, "    Write watchpoint %i set to %04X\n", c, watchw[c]);
                                                debug_out(outs);
                                                break;
                                        }
                                }
                                break;
                        }
                        if (!strncasecmp(ins, "wlist", 5))
                        {
                                for (c = 0; c < 8; c++)
                                {
                                        if (watchr[c] != -1)
                                        {
                                                sprintf(outs, "    Read watchpoint %i : %04X\n", c, watchr[c]);
                                                debug_out(outs);
                                        }
                                }
                                for (c = 0; c < 8; c++)
                                {
                                        if (watchw[c] != -1)
                                        {
                                                sprintf(outs, "    Write watchpoint %i : %04X\n", c, watchw[c]);
                                                debug_out(outs);
                                        }
                                }
                        }
                        if (!strncasecmp(ins, "wclearr", 7))
                        {
                                if (!params) break;
                                sscanf(&ins[d], "%X", &e);
                                for (c = 0; c < 8; c++)
                                {
                                        if (watchr[c] == e) watchr[c] = -1;
                                        if (c == e) watchr[c] = -1;
                                }
                        }
                        else if (!strncasecmp(ins, "wclearw", 7))
                        {
                                if (!params) break;
                                sscanf(&ins[d], "%X", &e);
                                for (c = 0; c < 8; c++)
                                {
                                        if (watchw[c] == e) watchw[c] = -1;
                                        if (c == e) watchw[c] = -1;
                                }
                        }
                        else if (!strncasecmp(ins, "writem", 6))
                        {
                                if (!params) break;
                                sscanf(&ins[d], "%X %X", &e, &f);
                                rpclog("WriteM %04X %04X\n", e, f);
                                writemem(e, f);
                        }
                        break;
                        case 'q': case 'Q':
                        setquit();
                        while (1);
                        break;
                        case 'h': case 'H': case '?':
                        sprintf(outs, "\n    Debugger commands :\n\n");
                        debug_out(outs);
                        sprintf(outs, "    bclear n   - clear breakpoint n or breakpoint at n\n");
                        debug_out(outs);
                        sprintf(outs, "    bclearr n  - clear read breakpoint n or read breakpoint at n\n");
                        debug_out(outs);
                        sprintf(outs, "    bclearw n  - clear write breakpoint n or write breakpoint at n\n");
                        debug_out(outs);
                        sprintf(outs, "    blist      - list current breakpoints\n");
                        debug_out(outs);
                        sprintf(outs, "    break n    - set a breakpoint at n\n");
                        debug_out(outs);
                        sprintf(outs, "    breakr n   - break on reads from address n\n");
                        debug_out(outs);
                        sprintf(outs, "    breakw n   - break on writes to address n\n");
                        debug_out(outs);
                        sprintf(outs, "    c          - continue running indefinitely\n");
                        debug_out(outs);
                        sprintf(outs, "    d [n]      - disassemble from address n\n");
                        debug_out(outs);
                        sprintf(outs, "    m [n]      - memory dump from address n\n");
                        debug_out(outs);
                        sprintf(outs, "    q          - force emulator exit\n");
                        debug_out(outs);
                        sprintf(outs, "    r          - print 6502 registers\n");
                        debug_out(outs);
                        sprintf(outs, "    r sysvia   - print System VIA registers\n");
                        debug_out(outs);
                        sprintf(outs, "    r uservia  - print User VIA registers\n");
                        debug_out(outs);
                        sprintf(outs, "    r crtc     - print CRTC registers\n");
                        debug_out(outs);
                        sprintf(outs, "    r vidproc  - print VIDPROC registers\n");
                        debug_out(outs);
                        sprintf(outs, "    r sound    - print Sound registers\n");
                        debug_out(outs);
                        sprintf(outs, "    s [n]      - step n instructions (or 1 if no parameter)\n\n");
                        debug_out(outs);
                        sprintf(outs, "    watchr n   - watch reads from address n\n");
                        debug_out(outs);
                        sprintf(outs, "    watchw n   - watch writes to address n\n");
                        debug_out(outs);
                        sprintf(outs, "    wclearr n  - clear read watchpoint n or read watchpoint at n\n");
                        debug_out(outs);
                        sprintf(outs, "    wclearw n  - clear write watchpoint n or write watchpoint at n\n");
                        debug_out(outs);
                        sprintf(outs, "    writem a v - write to memory, a = address, v = value\n");
                        debug_out(outs);
                        break;
                }
Ejemplo n.º 19
0
void ITG3200::setFilterBW(byte _BW) {   
  readmem(DLPF_FS, 1, &_buff[0]);
  writemem(DLPF_FS, ((_buff[0] & ~DLPFFS_DLPF_CFG) | _BW)); 
}
Ejemplo n.º 20
0
void SAT_Gyro::setYgyroStandby(bool _Status) {
  readmem(PWR_MGM, 1, &_buff[0]);
  writemem(PWR_MGM, ((_buff[0] & PWRMGM_STBY_YG) | _Status << 4));
}
Ejemplo n.º 21
0
void SAT_Gyro::setDevAddr(unsigned int  _addr) {
  writemem(WHO_AM_I, _addr);
  _dev_address = _addr;
}
Ejemplo n.º 22
0
void writes(const char *s)
{
	writemem(s, strlen(s));
}
Ejemplo n.º 23
0
void ITG3200::setClockSource(byte _CLKsource) {   
  readmem(PWR_MGM, 1, &_buff[0]);
  writemem(PWR_MGM, ((_buff[0] & ~PWRMGM_CLK_SEL) | _CLKsource)); 
}
Ejemplo n.º 24
0
void ITG3200::setLatchMode(bool _State) {
  readmem(INT_CFG, 1, &_buff[0]);
  writemem(INT_CFG, ((_buff[0] & ~INTCFG_LATCH_INT_EN) | _State << 5)); 
}
Ejemplo n.º 25
0
void ITG3200::setDevAddr(unsigned int  _addr) {
  writemem(WHO_AM_I, _addr); 
  _dev_address = _addr;
}
Ejemplo n.º 26
0
void ITG3200::setLatchClearMode(bool _State) {
  readmem(INT_CFG, 1, &_buff[0]);
  writemem(INT_CFG, ((_buff[0] & ~INTCFG_INT_ANYRD_2CLEAR) | _State << 4)); 
}
Ejemplo n.º 27
0
void ITG3200::setFSRange(byte _Range) {
  readmem(DLPF_FS, 1, &_buff[0]);   
  writemem(DLPF_FS, ((_buff[0] & ~DLPFFS_FS_SEL) | (_Range << 3)) ); 
}
Ejemplo n.º 28
0
void ITG3200::setITGReady(bool _State) {
  readmem(INT_CFG, 1, &_buff[0]);
  writemem(INT_CFG, ((_buff[0] & ~INTCFG_ITG_RDY_EN) | _State << 2)); 
}
Ejemplo n.º 29
0
void ITG3200::setINTLogiclvl(bool _State) {
  readmem(INT_CFG, 1, &_buff[0]);
  writemem(INT_CFG, ((_buff[0] & ~INTCFG_ACTL) | (_State << 7))); 
}
Ejemplo n.º 30
0
void SAT_Gyro::setSampleRateDiv(byte _SampleRate) {
  writemem(SMPLRT_DIV, _SampleRate);
}