OK, I have another problem. I have looked at this error message and cannot find out what is wrong.

Error:

flyingfisch@flyingfisch-Office-Computer:~/Desktop/PrizmSDK-0.3/projects/chess-timer$ make
/usr/local/cross/bin/sh3eb-elf-gcc -MMD -MP -MF /home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/build/chess-timer.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib -I/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/build -I/home/flyingfisch/Desktop/PrizmSDK-0.3/include -std=c99 -c /home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c -o chess-timer.o
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c: In function 'main':
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:21:3: warning: pointer targets in passing argument 1 of 'RTC_GetTime' differ in signedness [-Wpointer-sign]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/RTC_syscalls.h:4:6: note: expected 'unsigned int *' but argument is of type 'int *'
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:21:3: warning: pointer targets in passing argument 2 of 'RTC_GetTime' differ in signedness [-Wpointer-sign]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/RTC_syscalls.h:4:6: note: expected 'unsigned int *' but argument is of type 'int *'
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:21:3: warning: pointer targets in passing argument 3 of 'RTC_GetTime' differ in signedness [-Wpointer-sign]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/RTC_syscalls.h:4:6: note: expected 'unsigned int *' but argument is of type 'int *'
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:21:3: warning: pointer targets in passing argument 4 of 'RTC_GetTime' differ in signedness [-Wpointer-sign]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/RTC_syscalls.h:4:6: note: expected 'unsigned int *' but argument is of type 'int *'
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:25:3: warning: implicit declaration of function 'strcpy' [-Wimplicit-function-declaration]
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:25:3: warning: incompatible implicit declaration of built-in function 'strcpy' [enabled by default]
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:26:3: warning: pointer targets in passing argument 2 of 'itoa' differ in signedness [-Wpointer-sign]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/CONVERT_syscalls.h:6:6: note: expected 'unsigned char *' but argument is of type 'char *'
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:26:10: error: void value not ignored as it ought to be
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:27:3: warning: passing argument 3 of 'PrintXY' makes pointer from integer without a cast [enabled by default]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/display.h:28:6: note: expected 'char *' but argument is of type 'int'
make[1]: *** [chess-timer.o] Error 1
make: *** [build] Error 2


Code:

Code:

#include <display_syscalls.h>
#include <keyboard_syscalls.h>
#include <display_syscalls.h>
#include <display.h>
#include <keyboard.hpp>
#include <color.h>
#include <RTC_syscalls.h>
#include <CONVERT_syscalls.h>

int PRGM_GetKey(void);

int main() {
   int key;
   int hour, minute, second, ms;
   int done = 0;
   
   
   
   while (!done) {
      Bdisp_AllClr_VRAM();
      RTC_GetTime(&hour, &minute, &second, &ms);
      second = 10*(second&0xf0)+(second&0x0f);
      
      char buffer[10];
      strcpy(buffer,"  ");
      second = itoa(second, buffer+2);
      PrintXY(1, 1, second, TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
      Bdisp_PutDisp_DD();
      key = PRGM_GetKey();
      
      if (key == KEY_PRGM_MENU) {
         done = 1;
      }

   }
 
   return 1;
}


int PRGM_GetKey(void) {
  unsigned char buffer[12];
  PRGM_GetKey_OS( buffer );
  return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
}
Use unsigned int instead of int for hour, minute, second, and ms. Also, itoa doesn't return anything.
Still won't work.


flyingfisch@flyingfisch-Office-Computer:~/Desktop/PrizmSDK-0.3/projects/chess-timer$ make
/usr/local/cross/bin/sh3eb-elf-gcc -MMD -MP -MF /home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/build/chess-timer.d -Os -Wall -mb -m4a-nofpu -mhitachi -nostdlib -I/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/build -I/home/flyingfisch/Desktop/PrizmSDK-0.3/include -std=c99 -c /home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c -o chess-timer.o
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c: In function 'main':
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:25:3: warning: implicit declaration of function 'strcpy' [-Wimplicit-function-declaration]
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:25:3: warning: incompatible implicit declaration of built-in function 'strcpy' [enabled by default]
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:26:3: warning: pointer targets in passing argument 2 of 'itoa' differ in signedness [-Wpointer-sign]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/CONVERT_syscalls.h:6:6: note: expected 'unsigned char *' but argument is of type 'char *'
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:26:10: error: void value not ignored as it ought to be
/home/flyingfisch/Desktop/PrizmSDK-0.3/projects/chess-timer/src/chess-timer.c:27:3: warning: passing argument 3 of 'PrintXY' makes pointer from integer without a cast [enabled by default]
/home/flyingfisch/Desktop/PrizmSDK-0.3/include/display.h:28:6: note: expected 'char *' but argument is of type 'unsigned int'
make[1]: *** [chess-timer.o] Error 1
make: *** [build] Error 2



Code:

#include <display_syscalls.h>
#include <keyboard_syscalls.h>
#include <display_syscalls.h>
#include <display.h>
#include <keyboard.hpp>
#include <color.h>
#include <RTC_syscalls.h>
#include <CONVERT_syscalls.h>

int PRGM_GetKey(void);

int main() {
   int key;
   unsigned int hour, minute, second, ms;
   int done = 0;
   
   
   
   while (!done) {
      Bdisp_AllClr_VRAM();
      RTC_GetTime(&hour, &minute, &second, &ms);
      second = 10*(second&0xf0)+(second&0x0f);
      
      char buffer[10];
      strcpy(buffer,"  ");
      second = itoa(second, buffer+2);
      PrintXY(1, 1, second, TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
      Bdisp_PutDisp_DD();
      key = PRGM_GetKey();
      
      if (key == KEY_PRGM_MENU) {
         done = 1;
      }

   }
 
   return 1;
}


int PRGM_GetKey(void) {
  unsigned char buffer[12];
  PRGM_GetKey_OS( buffer );
  return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
}
This:

Code:
 second = itoa(second, buffer+2);

should be

Code:
 itoa(second, buffer+2);

Code:

#include <display_syscalls.h>
#include <keyboard_syscalls.h>
#include <display_syscalls.h>
#include <display.h>
#include <keyboard.hpp>
#include <color.h>
#include <RTC_syscalls.h>
#include <CONVERT_syscalls.h>

int PRGM_GetKey(void);

int main() {
   int key;
   unsigned int hour, minute, second, ms;
   int done = 0;
   
   
   
   while (!done) {
      Bdisp_AllClr_VRAM();
      RTC_GetTime(&hour, &minute, &second, &ms);
      second = 10*(second&0xf0)+(second&0x0f);
      
      char buffer[10];
      strcpy(buffer,"  ");
      itoa(second, buffer+2);
      PrintXY(1, 1, buffer, TEXT_MODE_NORMAL, TEXT_COLOR_BLACK);
      Bdisp_PutDisp_DD();
      key = PRGM_GetKey();
      
      if (key == KEY_PRGM_MENU) {
         done = 1;
      }

   }
 
   return 1;
}


int PRGM_GetKey(void) {
  unsigned char buffer[12];
  PRGM_GetKey_OS( buffer );
  return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
}


This code shows the numbers 1-10, and then skips to 160. Why? Isn't there a way to get it to go from 0-60 and back to zero?
Heh, that's my fault; the BCD to decimal code that I told you has a glitch. I forgot a left-shift by 4:


Code:
      second = 10*((second&0xf0)>>4)+(second&0x0f);
I wrote this little program for fun, but it won't work. I only get the loading symbol. I have a feeling this is because it is not displaying the VRAM.


Code:

#include <display_syscalls.h>
#include <keyboard_syscalls.h>
#include <display_syscalls.h>
#include <keyboard_syscalls.h>
#include <display_syscalls.h>
#include <display.h>
#include <keyboard.hpp>
#include <color.h>
#include <RTC_syscalls.h>
#include <CONVERT_syscalls.h>

void plot(int x0, int y0, int color);

 
int main() {
   int key;
   int color;
   int i;
   int j;
   int done;
   color = 0xFFFF;
   
   
   for(i = 1; i < LCD_HEIGHT_PX; 1) {
      for(j = 1; i < LCD_WIDTH_PX; 1) {
         plot(j, i, color);
         Bdisp_PutDisp_DD;
         color = color - 0x0001;
      }
   }
   
   while(!done) {
      key = PRGM_GetKey;
      switch(key) {
         case KEY_PRGM_MENU:
         done = 1;
         break;
      }
   }
     
 
   return 1;
}

 
void plot(int x0, int y0, int color) {
    char* VRAM = (char*)0xA8000000;
    VRAM += 2*(y0*LCD_WIDTH_PX + x0);
    *(VRAM++) = (color&0x0000FF00)>>8;
    *(VRAM++) = (color&0x000000FF);
    return;
 }
flyingfisch wrote:

Code:
         Bdisp_PutDisp_DD;

That's not a function call, it's just a nop.
OK, new question.

I know I saw how to do this somewhere but I can't find it back. How do I do a function that modifies a given variable?

The usage would be like this:

Code:

function (&var);



Thanks in advance Smile
flyingfisch wrote:
OK, new question.

I know I saw how to do this somewhere but I can't find it back. How do I do a function that modifies a given variable?

The usage would be like this:

Code:

function (&var);



Thanks in advance Smile


You'd have a signature something like this:


Code:
void function(int * var)


Inside the function you'd change the value like this:


Code:
*var = 5;
Ok, what does the "*" do? Isn't that multiplication?
flyingfisch wrote:
Ok, what does the "*" do? Isn't that multiplication?


http://pw1.netcom.com/~tjensen/ptr/pointers.htm Read.
flyingfisch wrote:
Ok, what does the "*" do? Isn't that multiplication?
Pointers and indirection are a key concept of C programming, and it's vital that you understand them properly.
Hi!

I'm trying to set up the Prizm SDK on my Ubuntu 12.04 machine. I read this guide. GCC and binutils are already installed on my computer, so I wouldn't like to install them again. So how should I configure them to get them into work?
There's no way around it, you need a cross-compiler for SH3. Your currently-installed GCC and binutils are (unless there's something very unusual going on) incapable of cross-compiling for SH3, as they target your system only.
Thanks, I did it!
My thread's bee hijacked!

No, Just Joking that's ok, anyone who wants to can post here Smile

but, i have another problem.


My code:


Code:

#include <display_syscalls.h>
#include <display.h>
#include <keyboard_syscalls.h>
#include <keyboard.hpp>

short unsigned int heightcolor(float z, float z_min, float z_max);
void fillArea(int x, int y, int width, int height, int color);

int main(void) {
   int ix;
   int key;
   int color;
   int done = 0;
   
   for (ix=1; LCD_WIDTH_PX; 1) {
      color = heightcolor(ix, 0, LCD_WIDTH_PX);
      fillArea(ix, 0, 1, LCD_HEIGHT_PX, color);
      Bdisp_PutDisp_DD();
   }
   
   while(!done) {
      GetKey(&key);
   
      switch(key) {
         case KEY_CTRL_MENU:
         done = 1;
         break;
      }
   }
 
   return 1;
}

short unsigned int heightcolor(float z, float z_min, float z_max) {
         float frac = ((z-z_min)/(z_max-z_min));
         
         //color!
         float r = (0.25f)-frac;
         float g = (0.5f)-frac;
         float b = (0.75f)-frac;

         //calculate the R/G/B values
         r = (r>0.f)?r:-r; g = (g>0.f)?g:-g; b = (b>0.f)?b:-b;   //absolute value
         r = (0.25f)-r; g = (1.f/3.f)-g; b = (0.25f)-b;   //invert
         r = (r>0.f)?(6.f*r):0.f; g = (g>0.f)?(6.f*g):0.f; b = (b>0.f)?(6.f*b):0.f;   //scale the chromatic triangles
         r = (r>1.f)?1.f:r; g = (g>1.f)?1.f:g; b = (b>1.f)?1.f:b;   //clip the top of the chromatic triangles
         if (frac < 0.25f) r = (r+1.f)/2.f;   //adjust the bottom end of the scale so that z_min is red, not black
         if (frac > 0.75f) b = (b+1.f)/2.f;   //adjust the top end of the scale so that z_max is blue, not black
         return (short unsigned int)(0x0000ffff & (((int)(31.f*r) << 11) | ((int)(63.f*g) << 5) | ((int)(31.f*b))));   //put the bits together
}

void fillArea(int x, int y, int width, int height, int color) {
    //only use lower two bytes of color
    char* VRAM = (char*)0xA8000000;
    VRAM += 2*(LCD_WIDTH_PX*y + x);
    for(int j=y; j<y+height; j++) {
       for(int i=x; i<x+width;  i++) {
          *(VRAM++) = (color&0x0000FF00)>>8;
          *(VRAM++) = (color&0x000000FF);
       }
       VRAM += 2*(LCD_WIDTH_PX-width);
    }
 }



It's supposed to draw a rainbow across the screen but all it succeeds in doing is freezing my calc. why?
flyingfisch wrote:

Code:
   for (ix=1; LCD_WIDTH_PX; 1) {

This loop can't terminate because it doesn't actually modify ix.

Code:
for (ix=1; LCD_WIDTH_PX; 1) {
This is not the syntax for for loops. This will loop infinitely. You want

Code:
for (ix=1; ix < LCD_WIDTH_PX; ix++) {


And also you probably want to start ix at 0.
ah, i get it.

Thanks Smile

another question.

this code works, but why does it change from full color mode to homescreen colors when i call GetKey?


Code:

#include <display_syscalls.h>
#include <display.h>
#include <keyboard_syscalls.h>
#include <keyboard.hpp>

short unsigned int heightcolor(float z, float z_min, float z_max);
void fillArea(int x, int y, int width, int height, int color);

int main(void) {
   int ix;
   int key;
   int color;
   int done = 0;
   
   for (ix=0; ix < LCD_WIDTH_PX; ix++) {
      color = heightcolor(ix, 0, LCD_WIDTH_PX);
      fillArea(ix, 0, 1, LCD_HEIGHT_PX, color);
      Bdisp_PutDisp_DD();
   }
   
   while(!done) {
      GetKey(&key);
   
      switch(key) {
         case KEY_CTRL_MENU:
         done = 1;
         break;
      }
   }
 
   return 1;
}

short unsigned int heightcolor(float z, float z_min, float z_max) {
         float frac = ((z-z_min)/(z_max-z_min));
         
         //color!
         float r = (0.25f)-frac;
         float g = (0.5f)-frac;
         float b = (0.75f)-frac;

         //calculate the R/G/B values
         r = (r>0.f)?r:-r; g = (g>0.f)?g:-g; b = (b>0.f)?b:-b;   //absolute value
         r = (0.25f)-r; g = (1.f/3.f)-g; b = (0.25f)-b;   //invert
         r = (r>0.f)?(6.f*r):0.f; g = (g>0.f)?(6.f*g):0.f; b = (b>0.f)?(6.f*b):0.f;   //scale the chromatic triangles
         r = (r>1.f)?1.f:r; g = (g>1.f)?1.f:g; b = (b>1.f)?1.f:b;   //clip the top of the chromatic triangles
         if (frac < 0.25f) r = (r+1.f)/2.f;   //adjust the bottom end of the scale so that z_min is red, not black
         if (frac > 0.75f) b = (b+1.f)/2.f;   //adjust the top end of the scale so that z_max is blue, not black
         return (short unsigned int)(0x0000ffff & (((int)(31.f*r) << 11) | ((int)(63.f*g) << 5) | ((int)(31.f*b))));   //put the bits together
}

void fillArea(int x, int y, int width, int height, int color) {
    //only use lower two bytes of color
    char* VRAM = (char*)0xA8000000;
    VRAM += 2*(LCD_WIDTH_PX*y + x);
    for(int j=y; j<y+height; j++) {
       for(int i=x; i<x+width;  i++) {
          *(VRAM++) = (color&0x0000FF00)>>8;
          *(VRAM++) = (color&0x000000FF);
       }
       VRAM += 2*(LCD_WIDTH_PX-width);
    }
 }
  
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
Page 5 of 6
» All times are GMT - 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