What are the definitions of w, depth_lut and angle_lut?

Code:
 double (*angle_lut)[240];
 double (*depth_lut)[240];
int w = 384;
I think it's too big:


Code:
Ethans-Mac-mini:~ ethan$ gcc spenceboy.c -o spenceboy
spenceboy.c: In function ‘main’:
spenceboy.c:11: warning: incompatible implicit declaration of built-in function ‘malloc’
Ethans-Mac-mini:~ ethan$ ./spenceboy
angle size 737280
depth size 737280
Ethans-Mac-mini:~ ethan$
parrotgeek1 wrote:
I think it's too big:


Code:
Ethans-Mac-mini:~ ethan$ gcc spenceboy.c -o spenceboy
spenceboy.c: In function ‘main’:
spenceboy.c:11: warning: incompatible implicit declaration of built-in function ‘malloc’
Ethans-Mac-mini:~ ethan$ ./spenceboy
angle size 737280
depth size 737280
Ethans-Mac-mini:~ ethan$


I'm not sure if this could be the problem. Could I get a second opinion from someone else?
Yeah, it's simply too large. Keep in mind that we have 2MB of RAM total, and only a small portion of that is available for programs' use, then consider that that's about 1.5 MB of memory total. IIRC, previous experiments indicated that you can only get about 64kB out of the system heap.
I had to make the width 32 to make it work, but here's a gif:
*BUMP*

So, I'm trying to port nCraft again. I think I'm having the same problems as before, but I have a better understanding now. I'm thinking the problem is that it doesn't have enough memory to alloc the gigantic world and other arrays. In SAX, AHelper suggested using heap instead(but since I have no idea how to use heap, I can't unless someone helps). Could someone help me with the heap(or some other idea to keep it from giving me a segfault)?

Edit:

I changed them to "array[bignumber]" instead and now I get another segfault from this bit of code:


Code:

void drawCubeList(float *cubePos,unsigned int *cubeList,int size,float xRotation,float zRotation)
{
  //one cube -- to translate to each pos of cubePos
  float cubeVertices[8*3]={1.0,1.0,1.0,  1.0,1.0,-1.0,  1.0,-1.0,1.0,  1.0,-1.0,-1.0,  -1.0,1.0,1.0,  -1.0,1.0,-1.0,  -1.0,-1.0,1.0,  -1.0,-1.0,-1.0};
  float cubeVerticesImg[8*3]={0.0};

  int cubeFaces[6*4]={1,2,4,3,  1,5,6,2,  1,3,7,5,  8,7,3,4,  8,7,5,6,  8,4,2,6};
  int colors[6]={2,4,6,8,10,12};
  int verticesPos[8*2]={0};
  int i=0;

  rotateZ(cubeVertices,8,zRotation);
  rotateX(cubeVertices,8,xRotation);

  //draw all cubes
  for(i=0;i<size;i++)
  {
    memcpy(cubeVerticesImg,cubeVertices,24*sizeof(float));

    translate(cubeVerticesImg,8,cubePos[i*3],cubePos[i*3+1],cubePos[i*3+2]);

    colors[0]=(int)(getCubeColor(cubeList[i]));
    colors[1]=shadeColor(colors[0],1);
    colors[2]=shadeColor(colors[0],-1);
    colors[3]=shadeColor(colors[0],1);
    colors[4]=colors[0];
    colors[5]=shadeColor(colors[0],-1);

    computeVertices(cubeVerticesImg,verticesPos,8);
    if(verticesPos[0]!=-10000)
      drawCube(cubeVerticesImg,verticesPos,cubeFaces,colors);
  }
}


Can anyone help?
*BUMP*

Okay. I'm trying to read a BMP file, and it doesn't seem to be working. It resets at this bit of code(it used to go back to the main menu, but now it resets):

(this is the part of the code that checks if it says BM at the beginning)

Code:

   Bfile_ReadFile_OS(hFile, blah, 1, 0);
   Bfile_ReadFile_OS(hFile, blah1, 1, 1);
   if(!(strtol(blah, NULL, 10) == 0x42 && strtol(blah1, NULL, 10) == 0x4d))
   {
      Bfile_CloseFile_OS(hFile);
      return 0;
   }
That.. makes basically no sense (strtol is entirely the wrong function to use here).

Code:
unsigned char sig[2];
Bfile_ReadFile_OS(hFile, sig, 2, 0);
if (strncmp(sig, "BM", 2) != 0) {
    // Fail
}

The BMP-loading code in mkg3a may also be enlightening (it does this same thing in a slightly different way).
Thank for your help. Now I get troubles here:

Code:

   j = 28;
    Bfile_ReadFile_OS(hFile, &blah, 2, j);
    if (blah != 16) {
      Bfile_CloseFile_OS(hFile);
      return 0;
   }


Some of you guys tried to help in SAX, but there was little progress. Will posting my code help?
First off, what endianness is the file? You are relying on the fact that the word is big-endian. To check, either use a hex viewer on the file or see if blah == 4096. If it does, you have the wrong endianness in the file.

What type is blah? What does the ReadFile call return?
blha is uint16_t. ReadFile returns the number of bytes read. Where did you get 4096 from? I checked the hex and it says 10 and 0x10 is 16.
Partly, it will return the bytes read or a negative value for an error code. For 4096, that is 0x1000. About 0x10, is it put in the file as 0x0010 or 0x1000? If you wrote 16 on an x86 machine, then it is 0x1000 (written directly from a 16 bit int).

Did you "see if blah == 4096"?
I jut check and it is indeed 4096. I have the wrong endianness?
Yes, if you wrote the file on a PC, please use hton and htons. These are functions to, well, Host to Network order (s for short, l for long). Network order is big-endian and host order is whatever your device is using, in this case little endian. It will, given a number, convert it to a big-endian number which the prizm will enjoy.

Quote:

x86:
0x10, 0x00
network/prizm:
0x00, 0x10
Okay. I got it to work. Very Happy Thanks for your help.
Here's a question:

Is there a routine for replacing text in a file with Bfile (or erasing it)?
Are you asking if a system call exists?
Or are you asking for something to do the work of writing such a routine for you?
Especially if the answer applies more to the second sentence I will leave you with a question instead of an answer.
The question is a simple one that has been asked many times not necessarily towards you but towards many people like you.
The question is: What have you tried?
Please do tell have you tried something or did you just make your post because the question has appeared into your head.
I ask this because this thread is already 13 pages and at some point in your life you are going to have to do learning yourself. To be a better programmer you are going to have to pass the stage where you ask people to do everything for you. It may work for a little while but at some point in time you will not ever receive a response because people are tired of doing all the work for you and you will be clueless on what to do.
Don't get me wrong I am not trying to be rude I wish to help you be a better programmer. To be a better programer you need to learn. I understand that some questions are justifiable when starting out but too much of anything can be bad. I would recomend you read http://mattgemmell.com/2008/12/08/what-have-you-tried/
ProgrammerNerd wrote:
I ask this because this thread is already 13 pages and at some point in your life you are going to have to do learning yourself. To be a better programmer you are going to have to pass the stage where you ask people to do everything for you. It may work for a little while but at some point in time you will not ever receive a response because people are tired of doing all the work for you and you will be clueless on what to do.
While I certainly understand and even in many cases echo your sentiment, that there are a lot of coders these days who just constantly ask questions and never really internalize the lessons, Spence has actually been doing a great deal better lately. His Prizm Paint program is actually progressing very nicely indeed, for example.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3 ... 11, 12, 13
» View previous topic :: View next topic  
Page 13 of 13
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement