Sega Saturn Development > General Jo Engine Help

Using other .c files to run functions externally?

(1/2) > >>

Mr. Potatobadger:
Hello!

First off, I want say I'm extremely impressed! This engine is really awesome! I can tell I'll be able to do some really cool stuff with it. I started using it just the other day, and I've picked it up super easily. I've only been able to use it inbetween my job, so I haven't made as much progress as I would have liked.

https://www.youtube.com/watch?v=jzX0Ek00HsI

I've been teaching myself how to use the engine with the demonstrations you see in the video there.

Anyways.

My issue is that I can't seem to use call functions from other .c files inside main.c.

It works just fine in the included Sonic example. In the Sonic example, main.c calls "load_sonic()" from sonic.c, to load sonic's sprite for use. Then "display_sonic()" is called to show sonic's sprite based on the conditions at the time, using variables defined in sonic.h.

I attempted to load a sprite using the exact same method in my project. The problem is, when I call the function I want in main.c to load my sprite, the compiler won't even compile. The compiler closes the second it is opened when I have that function listed. It's very strange! There must be something I'm doing wrong, or something I'm missing.

I'm really hoping you can help me out, Johannes, and I'm confident you can!

Thanks in advance :)

mindslight:
Hi Mr. Potatobadger  :),

Thanks for your feedback  ;)

Did you include your file in the makefile like this :

SRCS=main.c my_source.c
include ../Compiler/COMMON/jo_engine_makefile
If yes, make sure that the prototype of the function in "my_source.c" is well known on main.c, otherwise, the compiler with use interger (int) as defaut parameter types & return value.

The easiest way to test it is to declare at the top of "main.c" (after includes) the prototypes like this:

void  my_func_in_source_c(char *param1, int param2, etc);

Hope this will help you :)

PS: Nice demo btw  ;)




Mr. Potatobadger:
I completely forgot about the makefile! Including my other file in the makefile is definitely a step in the right direction, haha. However, it still does not compile.

This is my makefile:


--- Code: ---
SRCS=main.c ring.c
include ../Compiler/COMMON/jo_engine_makefile

--- End code ---

This is ring.h:


--- Code: ---
#ifndef __RING_H__
# define __RING_H__

#define RING_WIDTH (16)
#define RING_HEIGHT (16)

extern ring_t ring;

typedef struct
{
int ring_anim_id;
} ring_t;

void ring_display(void);
void ring_load(void);

#endif /* !__RING_H__! */

/*
** END OF FILE
*/

--- End code ---

And this is my ring.c:


--- Code: ---
#include <jo/jo.h>
#include "ring.h"

ring_t ring;

static const jo_tile ringframes[] =
{
{RING_WIDTH * 0, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 1, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 2, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 3, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 4, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 5, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 6, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 7, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 8, 0, RING_WIDTH, RING_HEIGHT},
{RING_WIDTH * 9, 0, RING_WIDTH, RING_HEIGHT},
};

inline void ring_display()
{
jo_sprite_draw3D2(jo_get_anim_sprite(ring.ring_anim_id), 0, 0, 450);
}

 void ring_load()
{
int sprite_id;

sprite_id = jo_sprite_add_bin_tileset("RING", "RING.BIN", JO_COLOR_Green, ringframes, JO_TILE_COUNT(ringframes));
ring.ring_anim_id = jo_create_sprite_anim(sprite_id, JO_TILE_COUNT(ringframes), 2);
}

--- End code ---

I feel like it should work, I'm hoping I'm just missing something obvious, or that I forgot a step.

I don't reference ring.c or ring.h in any way in main.c, and it still will not compile :(

mindslight:
Can you post the error log ?

Mr. Potatobadger:
Where do I find the error log?

Navigation

[0] Message Index

[#] Next page

Sitemap 1 2 3 4 5 6 7 8 9 10 
Go to full version