Change this:

Code:
Bdisp_PutDisp_DD( void );

to this:

Code:
Bdisp_PutDisp_DD();

You don't have KEY_PRGM_MENU declared, and you aren't using C99 mode.
I forget, how do you enable C99 mode? Also how do I declare KEY_PRGM_MENU?... I thought it is a defined key?
Add this to your code (or keyboard.hpp, so you can use it in other projects):

Code:
#define KEY_PRGM_MENU 48

Also, add -std=c99 to your CFLAGS in your Makefile. It should look like this:

Code:
CFLAGS   = -Os -Wall $(MACHDEP) $(INCLUDE) -std=c99
Okay thanks Souvik. One more things, well several I guess.
I don't understand the implicit declaration of drawline, or the undefined reference to those three. Could you help me? Thanks a ton!

Code:

In function 'main':
warning: implicit declaration of function 'drawline' [-Wimplicit-function-declaration]
Src.o: In function `_main':
Src.c:(.text.startup+0x80): undefined reference to `_drawline'
Src.c:(.text.startup+0xa0): undefined reference to `_PRGM_GetKey'
Src.c:(.text.startup+0xa4): undefined reference to `_keymenu'
drawLine is different from drawline. Wink

Code:
void drawLine(int x1, int y1, int x2, int y2, int color);


Code:
drawline(Ship_2X, Ship_2Y, Ship_3X, Ship_3Y, COLOR_BLUE);
Is that why these come up?

Code:

Src.o: In function `_main':
Src.c:(.text.startup+0xa0): undefined reference to `_PRGM_GetKey'
Src.c:(.text.startup+0xa4): undefined reference to `_keymenu'
You declare the PRGM_GetKey and keymenu functions at the top of your program, but there's no code for those functions later on.
Meaning I don't need them? When I take them out it returns even more errors. Sad I am confused.
No, you have to add the code for those functions:

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

Similarly, implement the keymenu function.
Ahhh, I wasn't thinking they were functions, duh. Thanks again.

Ashbad siad he knew a good routine that would fill the screen with a specific color. I looked but didn't see anything but fillArea. He said something about mmset? Something with "m", anyways does anyone have a good routine that fills the screen? Thanks
zeldaking wrote:
Ahhh, I wasn't thinking they were functions, duh. Thanks again.

Ashbad siad he knew a good routine that would fill the screen with a specific color. I looked but didn't see anything but fillArea. He said something about mmset? Something with "m", anyways does anyone have a good routine that fills the screen? Thanks


Well, something like this would be ideal:


Code:
for(int i = 0; i < LCD_WIDTH_PX*LCD_HEIGHT_PX/2; i++) {
  *((int*)0xA8000000+i) = (COLOR<<16)|COLOR;
}


Just insert where needed and replace COLOR with either the color_t value or a valid color_t define in color.h that Merth made a while back. Fastest way possible.

Edit: okay, maybe unrolling it would make it faster, but you know what I mean Wink
Thanks, yeah I am doing

Code:

void full_screen_color(int COLOR){
   for(int i = 0; i < LCD_WIDTH_PX*LCD_HEIGHT_PX/2; i++) { 
      *((int*)0xA8000000+i) = (COLOR<<16)|COLOR; 
   }
}

And it works great, thanks.

*Question:*
I have my ship located at:

Code:

Ship_X=198;
Ship_Y=112;

But it renders at the top left of the screen. Does anyone know why? These coordinates should be in the middle.
Well, you never call Init(). If you want to call Init() before the main function, you'll probably have to edit crt0.
souvik1997 wrote:
you'll probably have to edit crt0.
...

Or just call Init at the beginning of main like a sane person.
I said before the main function, the way he was using the Init function looked like he wanted that to run before any code in the main function. Of course, calling Init() is a much better solution.
Nah I changed it up, they initilize at the begining, i.e. int Ship_1X=190;

Code:

int main(void) {
   full_screen_color(COLOR_BLACK);
   drawship();
  while(true) {     
    if(PRGM_GetKey() == KEY_PRGM_MENU) {   
      keymenu();
    }
   GetKey(&key);
   if (keydown(KEY_PRGM_UP)) {   
      Y_Move--;
      } else if (keydown(KEY_PRGM_DOWN)) {   
      Y_Move++;
     } else if (keydown(KEY_PRGM_LEFT)) {
      X_Move--;
     } else if (keydown(KEY_PRGM_RIGHT)) {
      X_Move++;
     }
     //Move update
   if (Y_Move) {
      DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
      Ship_1Y=Ship_1Y+Y_Move;
      drawship(); }
   if (X_Move) {
      DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
      Ship_1X=Ship_1X+X_Move;
      drawship(); }
    //Screen boundaries scroll
   if (Ship_1X<7) {
      DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
      Ship_1X=389;
      drawship(); }
   if (Ship_1X>389) {
      DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
      Ship_1X=7;
      drawship(); }
   if (Ship_1Y<7) {
      DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
      Ship_1Y=217;
      drawship(); }
   if (Ship_1Y>217) {
      DrawCircle( Ship_1X, Ship_1Y, 5, COLOR_BLACK);
      Ship_1Y=7;
      drawship(); } 
  }   
  return 0;   


This is my main code so far, notice the ship is just a circle right now. I am drawing a black circle where the prevoius circle was to "erase" it. Is there a better way to erase the ship (while possibly keeping background?).
Next problem, where it says "move update" it is supposed to keep moving by adding the X and Y move increments, but odly it only increments when I push the arrow (actually any) keys. How come? (drawship updates Bdisp_PutDisp_DD();, so that isn't the problem.
Thanks for the support.
I have the suspicion that

Code:

if(PRGM_GetKey() == KEY_PRGM_MENU) {   
      keymenu();
    }

pauses the execution until key press, but I am not sure.
Try removing this line:

Code:
   GetKey(&key);

The GetKey() syscall is blocking, meaning that it will wait for you to press a key.
zeldaking wrote:
Is there a better way to erase the ship (while possibly keeping background?).
Yes, it's called sprite XORing, and it works just as well in color as it does in black-and-white. Unfortunately, if you have a varied background, it can get ugly. Therefore, one strategy is to save the rectangle of background that the sprite will cover in a small array, draw the sprite on top, then draw the background back from its array when you want to erase the sprite.
Well asteroids doens't use sprites, err vector sprites that is. Luckly asteroids has a good black background so it shouldn't get too ugly, the circle as the ship is temporary untill further coding. I was just wondering Smile Thanks.
So is there any particular reason why this topic (and the first sentence in the first post) is still called "Asteriods" and not "Asteroids"?
  
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 3 of 5
» 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