I'm now trying to find how to zoom in on something in c, but I can't find anything on google. Can anyone help?
Spenceboy98 wrote:
I'm now trying to find how to zoom in on something in c, but I can't find anything on google. Can anyone help?


Define what you mean by "zooming in on something". Perhaps you mean scaling sprites to be larger?
Ashbad wrote:
Spenceboy98 wrote:
I'm now trying to find how to zoom in on something in c, but I can't find anything on google. Can anyone help?


Define what you mean by "zooming in on something". Perhaps you mean scaling sprites to be larger?


Sort of like that. Like zooming in on a part of the screen. So you can see each pixel.
I'm trying to use gbl08ma's file browser, but I keep getting this error:

Code:
main.o: In function `_fileBrowser.constprop.3':
main.c:(.text+0x290): undefined reference to `_strcpy'
main.c:(.text+0x2b4): undefined reference to `_strcmp'
main.c:(.text+0x4c8): undefined reference to `_memset'
main.c:(.text+0x500): undefined reference to `_strcpy'
main.c:(.text+0x88c): undefined reference to `_strcpy'
main.c:(.text+0x8ac): undefined reference to `_strcmp'
main.c:(.text+0x98c): undefined reference to `_memset'
main.c:(.text+0x994): undefined reference to `_strcpy'
main.o: In function `_GetFiles':
main.c:(.text+0x1d3c): undefined reference to `_strcpy'
main.c:(.text+0x1d58): undefined reference to `_strcmp'
main.o: In function `_fileBrowser':
main.c:(.text+0x2004): undefined reference to `_memset'
main.c:(.text+0x2038): undefined reference to `_strcpy'
main.c:(.text+0x2434): undefined reference to `_strcpy'
main.c:(.text+0x2444): undefined reference to `_strcmp'
main.c:(.text+0x2450): undefined reference to `_memset'
collect2: ld returned 1 exit status


I had it working on one of my other programs, but I can't figure out what's wrong here. I am pretty sure that it isn't my code giving the problem.
Do you have the latest version of libfxcg.a from Tari's Jenkins for it?
Tari wrote:
Spenceboy98 wrote:
I'm having trouble figuring out this error. I have stdlib.h included:
Looks like an oversight while we were reorganizing headers. I'll verify and push a fix momentarily.
EDIT:
Oh, no. Either you have an old copy of libc.a, or your Makefile needs to be updated to use libc rather than libfxcg.

Probably still an issue with this. What's your Makefile look like?
Now I need help with this:

Code:
    if(!(buffer[1] == '\n')){
    if(keydownlast(KEY_PRGM_RETURN) && keydownhold(KEY_PRGM_RETURN))
        break;
    }


I'm trying to get it to break out of a while loop when a number is entered and you press [EXE]. It comes up on the screen for a second and disappears before I can type anything in. Any help?

On page nine of the Useful Prizm Routines thread, Tari posted the scrollable menu. I wondering how to make it do something for the first choice. It seems that choice 2 = 1 and choice 3 = 2 and so on. What is the value for the first choice?

Kerm, for your Text and Number Input, how do I store the value inputted into a variable? It only lets me put it into a char.


Edit:
Quote:
Now I need help with this:

Code:
    if(!(buffer[1] == '\n')){
    if(keydownlast(KEY_PRGM_RETURN) && keydownhold(KEY_PRGM_RETURN))
        break;
    }


I'm trying to get it to break out of a while loop when a number is entered and you press [EXE]. It comes up on the screen for a second and disappears before I can type anything in. Any help?


I fixed this problem. I changed the \n to \0. I still need help with the other questions though, so it would be nice if you did. Wink
Quote:
On page nine of the Useful Prizm Routines thread, Tari posted the scrollable menu. I wondering how to make it do something for the first choice. It seems that choice 2 = 1 and choice 3 = 2 and so on. What is the value for the first choice?
Presumably choice 1 = 0. It's very common to zero-index among C and ASM (and many other) programers.

Quote:
Kerm, for your Text and Number Input, how do I store the value inputted into a variable? It only lets me put it into a char.
That's what the bug argument is for:
Quote:
char* buf - A buffer of at least maxstrlen+1 characters. May contain initial contents or just '\0'.
KermMartian wrote:
Quote:
On page nine of the Useful Prizm Routines thread, Tari posted the scrollable menu. I wondering how to make it do something for the first choice. It seems that choice 2 = 1 and choice 3 = 2 and so on. What is the value for the first choice?
Presumably choice 1 = 0. It's very common to zero-index among C and ASM (and many other) programers.


I've tried that. 0 is the default if nothing is pressed from what I can see.


Edit:
Also, what do you mean by "the bug argument"? Did you mean buf? When I said variable, I meant an integer variable(sorry).
You can't pass it an integer pointer; you need to pass it a character array. And yes, I did indeed mean buf.
KermMartian wrote:
You can't pass it an integer pointer; you need to pass it a character array. And yes, I did indeed mean buf.


But what If I want to change an integer variable by inputting? Is there a way? Is it possible?
*BUMP*
Kerm can you answer that question^^?

Also, is there a way to display the value of an integer with PrintMiniFix?
Why not use sprintf or itoa?
Itoa isn't working, and sprintf makes it display letters and symbols that don't change when the variable changes.

itoa keeps giving me:

Code:
error: too many arguments to function 'itoa'


This is the code:

Code:
itoa(r, rbuf, 10);
Our itoa() is not the same as this itoa. If you looked at the header file for itoa(), you'd see that our version just takes the buffer as its single argument, as I recall. itoa() isn't really a stdlib function anyway, so you should avoid it if you can. sprintf is a good alternative.
Is there a way to change a char to an int(so that I can use Kerm's input routine to change integers)?
A little while back, I tried to port the nCraft, but I'm a n00b, so I couldn't, and still can't, figure out what is making it give a segfault. I tried my best, but maybe one of you guys can fix it(or just port it from the original source which is probably in the latest download on omnimaga), if you want.

Here is my code in a zip: http://www.mediafire.com/?ufvhocjm9d82u48
*BUMP*
I'm trying to get the colory version of t0xic_kitt3n's mode 7 engine. I'm not sure this part of the code is working correctly.


Code:
void m7LoadTex(unsigned int tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE], ...) {
    va_list ap;
    int i, j, k;

    va_start(ap, tex);
    for (i = 0; i < M7_NUM_TEX; ++i) {
        const int* blob = va_arg(ap, const int*);
        for (j = 0; j < M7_TEX_SIZE; j++)
            for (k = 0; k < M7_TEX_SIZE; k++)
                tex[i][j][k] = blob[k*j];
    }
    va_end(ap);
}


To get the individual color from an color_t sprite, do I do sprite[k*j]? Or something else?

Also, here is the code after it that uses the tex[][][] to render it. Can you see anything wrong/weird?


Code:
void m7Render(m7Vec_t lut[M7_SCREEN_HEIGHT],
              unsigned int tilemap[M7_MAP_SIZE][M7_MAP_SIZE],
              unsigned int tex[M7_NUM_TEX][M7_TEX_SIZE][M7_TEX_SIZE],
              m7Vec_t pos,
              int heading) {
    int screenX, screenY;
    for (screenY = (M7_SCREEN_HEIGHT / 2) + 1; screenY < M7_SCREEN_HEIGHT; ++screenY) {
        m7Vec_t map = lut[screenY];
        m7Vec_t mapXStep = {-map.x / (M7_SCREEN_WIDTH / 2), 0};

        int sinHeading = m7SinLut(heading);
        int cosHeading = m7CosLut(heading);

        m7RotateVec(&map, sinHeading, cosHeading);
        m7RotateVec(&mapXStep, sinHeading, cosHeading);

        map.x += pos.x;
        map.y += pos.y;

        for (screenX = 0; screenX < M7_SCREEN_WIDTH; ++screenX) {
            unsigned int color = 0;

            if (map.x >= 0 && map.x < M7_INT_TO_FIX(M7_MAP_SIZE)
             && map.y >= 0 && map.y < M7_INT_TO_FIX(M7_MAP_SIZE))
                color = tex[(int)tilemap[map.y >> M7_TEX_SIZE][map.x >> M7_TEX_SIZE]][(map.y & 0xFFFF) >> 12][(map.x & 0xFFFF) >> 12];

            map.x += mapXStep.x;
            map.y += mapXStep.y;

            plot(screenX, screenY, color);
        }
    }
    Bdisp_PutDisp_DD();
}


I'm asking about these because it is rendering weird. A corner of each tile is black, plus the colors change every time you move. Any suggestions?

Edit:
Here are some screenshots so you can see.

When you begin the addin:


When you move forward a little:


When you get to the edge:


When you turn to the left at the edge:
> I think the issue is m7render(), not m7LoadTex(), because the latter presumably runs only once.
> In myLoadTex(), the correct element fetch would be blob[j*M7_TEX_SIZE+k], but blob should also be defined as a color_t* instead of an int*, if it is a pointer to an array of color_ts.
> Similarly, in m7render(), I think you should use color_t tex instead of unsigned int tex. That could easily explain your issue, because an int is 32 bits on a Prizm, while a color_t is 16 bits.
KermMartian wrote:
> I think the issue is m7render(), not m7LoadTex(), because the latter presumably runs only once.
> In myLoadTex(), the correct element fetch would be blob[j*M7_TEX_SIZE+k], but blob should also be defined as a color_t* instead of an int*, if it is a pointer to an array of color_ts.
> Similarly, in m7render(), I think you should use color_t tex instead of unsigned int tex. That could easily explain your issue, because an int is 32 bits on a Prizm, while a color_t is 16 bits.


I tried color_t, but it didn't work before. It just changed it to int. Now I moved the define of color.h, so that works now.

I keep getting

Code:
error: assignment of read-only variable 'color'


This is the line of code it is talking about:

Code:
color = tex[(int)tilemap[map.y >> M7_TEX_SIZE][map.x >> M7_TEX_SIZE]][(map.y & 0xFFFF) >> 12][(map.x & 0xFFFF) >> 12];


Suggestions?

Edit: Nevermind. I defined color ans const color_t. Had to take out the const. Razz

Edit2:
Now it displays the textures correctly, but the colors still change as the player moves. Plus it still has the turning problem and the edge of map problem.

Here is the other routine that is in the main loop with the stuff that it includes:

Code:

#define M7_FIX_MUL(a, b) ((int)(((long int)(a) * (long int)(b)) >> 16))

typedef struct m7Vec_t {
    int x;
    int y;
} m7Vec_t;

// The function in the main loop

m7Vec_t* m7RotateVec(m7Vec_t* a, int sine, int cosine) {
    m7Vec_t tmp = *a;
    a->x = M7_FIX_MUL(tmp.x, cosine) - M7_FIX_MUL(tmp.y, sine);
    a->y = M7_FIX_MUL(tmp.x, sine) + M7_FIX_MUL(tmp.y, cosine);
    return a;
}
  
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 ... 10, 11, 12, 13  Next
» View previous topic :: View next topic  
Page 11 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