Go to Post just watch out for the evil, robot devouring ghosts - Mr. Pockets [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-08-2013, 00:35
jeidee jeidee is offline
Registered User
no team
 
Join Date: Aug 2013
Location: manila
Posts: 2
jeidee is an unknown quantity at this point
Help me to convert in delphi

hi guys pls help me


Help me to convert in delphi



Code:
#include <stdio.h> 
#include <stdlib.h> 
#include <memory.h> 

unsigned int    rng_vec[607]; 
unsigned int *    rng_tap = rng_vec; 
unsigned int *    rng_feed = 0; 


// 123456005883380 - 65863543 
// 21 43 65 00 85 38 83 f0 

  int v3; // r5@1 
  unsigned int v4; // r0@1 
  int v5; // r4@1 
  unsigned int v6; // r1@2 
  char *v7; // r2@2 
  unsigned int v8; // r0@3 
  int v9; // r4@3 
  unsigned int v10; // r1@4 
  signed int v11; // r0@5 
  signed int v12; // r0@5 
  int cnt; // r0@5 
  int v14; // r1@6 
  char v16[8]; // [sp+0h] [bp-20h]@1 
  char v17[8]; // [sp+8h] [bp-18h]@1 


  char Table_00[10] =       {    0,   6,   1,   8,   7,   5,   3,   2,    
9,   4}; 
  char Table_01[10] =       {    0,   2,   6,   6,   9,   5,   1,   4,    
3,   8}; 
  char Table_10[10] =       {    0,   4,   9,   2,   3,   5,   7,   8,    
1,   6}; 
  char Table_11[10] =       {    0,   8,   3,   4,   1,   5,   9,   6,    
7,   2}; 

  char Table_2[100] = {          
                  0x11, 0x5D, 0x5B, 0x5A, 0x58, 0x57, 5, 7, 9, 0x12, 
                  1, 0x45, 0x51, 0x50, 0x4E, 0x18, 0x16, 0x13, 0x1F, 
                  0x64, 2, 0x1E, 0x3C, 0x24, 0x23, 0x3F, 0x43, 0x2A, 
                  0x47, 0x63, 0xC, 0x1D, 0x44, 0x32, 0x35, 0x38, 0x2B, 
                  0x21, 0x48, 0x59, 0xF, 0x1C, 0x27, 0x37, 0x2C, 0x31, 
                  0x36, 0x3E, 0x49, 0x56, 0x55, 0x1B, 0x28, 0x2D, 0x3A, 
                  0x33, 0x30, 0x3D, 0x4A, 0x10, 0x5F, 0x4B, 0x25, 0x34, 
                  0x2F, 0x2E, 0x39, 0x40, 0x1A, 6, 0x61, 0x4C, 0x3B, 
                  0x41, 0x42, 0x26, 0x22, 0x29, 0x19, 4, 0x62, 0x46, 
                  0x14, 0x15, 0x17, 0x4D, 0x4F, 0x52, 0x20, 3, 0x53, 
                  8, 0xA, 0xB, 0xD, 0xE, 0x60, 0x5E, 0x5C, 0x54}; 

 char coda[8]; 
  
unsigned int isrand(unsigned int _seed) 
{ 
  unsigned int result; // r0@1 
  unsigned int seed; // r1@1 
  signed int i; // r4@3 

  rng_tap = rng_vec; 
  rng_feed = rng_vec+607-273; 
  seed = _seed % 0x7FFFFFFF; 
  result = _seed / 0x7FFFFFFF; 
  if ( !seed ) 
    seed = 89482311; 
  for ( i = -20; i < 607; i = (i + 1) ) 
  { 
    result = 3399 * (seed / 44488); 
    seed = 48271 * (seed % 44488) - 3399 * (seed / 44488); 
    if ( i >= 0 ) 
    { 
      result = 4 * i; 
      rng_vec[i] = seed; 
    } 
  } 
  return result; 
} 


unsigned int lrand() 
{ 
  int v0; // r0@5 
  unsigned int result; // r0@7 

  --rng_tap; 
  if ( rng_tap < rng_vec ) 
  { 
    if ( !rng_feed ) 
    { 
      isrand(1u); 
      --rng_tap; 
    } 
    rng_tap += 607; 
  } 
  //v0 = rng_feed - 4; 
  rng_feed--; // = v0; 
  if ( rng_feed < rng_vec ) 
     rng_feed +=607; //rng_feed +=2428; 
  result = (2 * (*rng_feed + *rng_tap)) >> 1; 
  *rng_feed = result; 
  return result; 
} 


int main(int argc, char* argv[]) 
{ 
  int v15; 
  unsigned int imei=atoi(argv [1]); 
   
  
  // printf("%i",imei);   
//IMEI =   TAC + FAC +   SNR + LUHN 
//       XXXXXX + YY + ZZZZZZ + L 
 //v4 = SNR + MAGIC 


//SNR = XXXXXXX-YY-429081-L 
//MAGIC = 313944551; 

  //v4 = 441525 + 313944551; 
  v4 = imei + 313944551; 
  v5 = 0; 
  do 
  { 
    v6 = v4 % 0xA; 
    v4 /= 0xAu; 
    v15 = 5 - v5++; 
    v17[v15] = v6; 
  } 
  while ( v5 < 6 ); 
  v8 = (13 * v17[5] + 5 * v17[4] + 3 * v17[3] + 1553 * v17[2] + 23 *  
v17[1] + 177 * v17[0]) % 99999; 
  v9 = 7; 
  do 
  { 
    v10 = v8 % 0xA; 
    v8 /= 0xAu; 
    v17[v9] = v10; 
    v9 = (v9 + 255) & 0xFF; 
  } 
  while ( v9 > 5 ); 
  v16[0] = Table_00[v17[0]]; 
  v16[1] = Table_01[v17[1]]; 
  v16[2] = Table_10[v17[2]]; 
  v16[3] = Table_11[v17[6]]; 
  v11 = Table_2[(10 * v17[3]) + v17[4]] - 1; 
  v16[4] = v11 / 10; 
  v16[5] = v11 % 10; 
  v12 = Table_2[99 - ((10 * v17[7]) + v17[5])] - 1; 
  v16[6] = v12 / 10; 
  v16[7] = v12 % 10; 
  cnt = 0; 
  v3 = 0; 
  do 
  { 
   v14 = (v16[cnt] << 4 * cnt) | v3; 
    cnt = (cnt + 1) & 0xFF; 
    v3 = v14; 
  } 
  while ( cnt < 8 ); 
  v14 = 0; 
  isrand(v3); 
  do 
    coda[v14++] = lrand() % 0xA + 48; 
  while ( v14 < 8 ); 

  
     printf("%s",coda);   

    return 0; 
}
  #2   Spotlight this post!  
Unread 02-08-2013, 01:30
Joe G.'s Avatar
Joe G. Joe G. is online now
Taking a few years (mostly) off
AKA: Josepher
no team (Formerly 1687, 5400)
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2007
Location: Worcester, MA
Posts: 1,453
Joe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond reputeJoe G. has a reputation beyond repute
Send a message via AIM to Joe G.
Re: Help me to convert in delphi

Welcome,

Despite its name, this forum primarily deals with the FIRST Robotics Competition, rather than delphi programming. You probably won't have much luck getting help with delphi here.
__________________
FIRST is not about doing what you can with what you know. It is about doing what you thought impossible, with what you were inspired to become.

2007-2010: Student, FRC 1687, Highlander Robotics
2012-2014: Technical Mentor, FRC 1687, Highlander Robotics
2015-2016: Lead Mentor, FRC 5400, Team WARP
2016-???: Volunteer and freelance mentor-for-hire
  #3   Spotlight this post!  
Unread 02-08-2013, 02:01
CalTran's Avatar
CalTran CalTran is offline
MST Rolla Senior
FRC #2410 (BV CAPS Metal Mustang Robotics)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: Overland Park, Kansas
Posts: 2,419
CalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond reputeCalTran has a reputation beyond repute
Re: Help me to convert in delphi

Can't tell if spam or not...could just be one of the bots that'll add the links to it's signature later...
__________________
Team 2410 thinks KISSing is amazing! Keep It Super Safe!
  • "You know you've been in robotics too long when you start talking to your tools." "Well, you've been in robotics CLEARLY too long when they start talking back"
  • Theory is when you know everything but nothing works. Practice is when everything works but you don't know why. On our team, theory and practice comes together - nothing works and nobody knows why.
MMR 2410 Student (2010 - 2013) | MMR 2410 Mentor (2013 - Present)
FTC Game Announcer / EmCee (2014 - Present) | FRC EmCee (2015 - Present) | FRC Referee (2016) | FTC Referee (2017)
Academic Student (Forever)
  #4   Spotlight this post!  
Unread 02-08-2013, 02:21
Woolly's Avatar
Woolly Woolly is offline
Programming Mentor
AKA: Dillon Woollums
FRC #1806 (S.W.A.T.)
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Springfield, MO
Posts: 512
Woolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond reputeWoolly has a reputation beyond repute
Re: Help me to convert in delphi

Quote:
Originally Posted by CalTran View Post
Can't tell if spam or not...could just be one of the bots that'll add the links to it's signature later...
This guy actually seems legit, it's understandable that a person from the Philippines would have poor English (no offense), and wouldn't know what Chief Delphi is actually for.

Well, unless he's on team 3105, in which case he doesn't have much excuse. Probably not though.
__________________


Team 1806 Student: 2012-2013 | Mentor: 2013-Present
  #5   Spotlight this post!  
Unread 02-08-2013, 06:14
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Help me to convert in delphi

C 2 Delphi Converter 1.0 at tucows.com, is what I got with Google. (Googling "dephi" doesn't pick up this website at all.) That's probably all the help we can give you. We also don't give answers to homework problems. In that light, jeidee, can you tell us what this code is doing and how you came on it? It might give us a clue how to help you. I do find the "MAGIC" variable interesting (though commented out).
  #6   Spotlight this post!  
Unread 02-08-2013, 06:21
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: Help me to convert in delphi

Quote:
Originally Posted by Roger View Post
C 2 Delphi Converter 1.0 at tucows.com, is what I got with Google. (Googling "dephi" doesn't pick up this website at all.) That's probably all the help we can give you. We also don't give answers to homework problems. In that light, jeidee, can you tell us what this code is doing and how you came on it? It might give us a clue how to help you. I do find the "MAGIC" variable interesting (though commented out).
If you google "delphi forum" or "delphi forums" we are ranked highly in the first page of results.
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.
  #7   Spotlight this post!  
Unread 02-08-2013, 07:40
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 688
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Help me to convert in delphi

delphi
delphi programming
delphi programming help
delphi translate
c to delphi translate


is what I would search for to translate a C program to Delphi.

Or some good Delphi and C books (or on-line equivalent) and a piece of paper to figure out the code.

If I found a Delphi forum in a search, I would in all honesty read the linked thread, then search thru the forum to see if there is a similar question or at least find out if the forum is where I want to take the time to register to ask the question.

Finding a "Delphi" forum that has under it's technical forums lists Motors, Electrical, Control System, and Pneumatics on either side of the Programming forum (not to mention a programming forum that has questions about robots, IP addresses, image processing, Arduinos, as well as a sticky title "If you come here asking for Delphi programming..." that I would read first before registering) would give me pause that maybe, just maybe, this place isn't about the programming language Delphi.

But I was polite and did ask jeidee for more information about his/her question. I am curious what the code is intended to perform. I have my suspicions.
  #8   Spotlight this post!  
Unread 02-08-2013, 20:19
GaryVoshol's Avatar
GaryVoshol GaryVoshol is offline
Cogito ergo arbitro
no team
 
Join Date: Aug 2005
Rookie Year: 2000
Location: Royal Oak, MI
Posts: 5,762
GaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond reputeGaryVoshol has a reputation beyond repute
Re: Help me to convert in delphi

This thread has run through it's usefulness. Closing.
__________________
(since 2004)
  #9   Spotlight this post!  
Unread 02-08-2013, 21:27
jeidee jeidee is offline
Registered User
no team
 
Join Date: Aug 2013
Location: manila
Posts: 2
jeidee is an unknown quantity at this point
why my thread is close?

why my thread is close?

this is the link

http://www.chiefdelphi.com/forums/sh...hlight=convert


no one can answer my question


sorry if i have bad words or anything that the rules i break?
  #10   Spotlight this post!  
Unread 03-08-2013, 00:12
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: why my thread is close?

This forum does not have anything to do with the Delphi programming language; this forum is dedicated to discussing the FIRST Robotics Competition.

So it is highly unlikely that anyone here will be able to help you with Delphi programming language questions. No rules were broken on your behalf, we just can't help you answer your questions.

Please refer to the sticky thread here:
http://www.chiefdelphi.com/forums/sh...ad.php?t=29944
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:28.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi