Conversation Between jiangzhengwenjzw and Blah
Showing Visitor Messages 46 to 60 of 89
-
March 26th, 2016 5:31 AMBlahyeah this works. Try it
-
March 26th, 2016 5:21 AMjiangzhengwenjzwI think I do exactly what you said, but it doesn't work lol
Have you yourself tried this way to compile? -
March 26th, 2016 5:17 AMBlahextern void func_2();
void func_1() { func_2();}
---
void func_2() {} -
March 26th, 2016 5:10 AMjiangzhengwenjzwI don't understand. Would you mind showing me an example?
-
March 26th, 2016 5:03 AMBlahextern does work in devkitarm. Devkitarm is based off of GCC.
extern the entire function header. -
March 26th, 2016 4:34 AMjiangzhengwenjzwYes, apparently I use extern in the file using those functions. (example, extern xxxx in main.c, and the xxxx is defined in another .c file)
But it simply didn't work :(
For including, when I'm C programming before trying on GBA, I was used to include only header files and using extern mark to get functions in other source files. Therefore I want to know if it's possible to do it with devkitarm. -
March 26th, 2016 4:23 AMBlahExtern is how you would do it.
Make sure you have the extern statement in the file which uses the functions, and not in the original file. Also what's wrong with including them? -
March 26th, 2016 4:08 AMjiangzhengwenjzwOK, i'm here for another question.
What should I do to use functions, arrays defined in other .c files? I know that we can simply include those files, but that's really silly.
I've tried to use the "extern" mark when declaring those functions/arrays, but it simply has no effect. -
March 24th, 2016 3:47 PMjiangzhengwenjzwok. I think that's the simplest way haha
-
March 24th, 2016 7:57 AMBlahjust copy it over, and change the "<>" to just normal double quotes :)
-
March 24th, 2016 7:34 AMjiangzhengwenjzwI must say that I don't understand.
I think simply copying the header file won't work, because this is the content of gba.h:
//---------------------------------------------------------------------------------
#ifndef _gba_h_
#define _gba_h_
//---------------------------------------------------------------------------------
#include <gba_affine.h>
#include <gba_compression.h>
#include <gba_console.h>
#include <gba_dma.h>
#include <gba_input.h>
#include <gba_interrupt.h>
#include <gba_multiboot.h>
#include <gba_sio.h>
#include <gba_sound.h>
#include <gba_sprites.h>
#include <gba_systemcalls.h>
#include <gba_timers.h>
#include <gba_video.h>
//---------------------------------------------------------------------------------
#endif //_gba_h
//---------------------------------------------------------------------------------
You can see that it uses the <> mark...
For the "search path", i still don't know what to do. Would you give me some explicit instructions? I'm not a programmer lool -
March 24th, 2016 4:38 AMBlahYou can always copy that directory into your project folder and use the
"#include "gba.h".
Otherwise you need to ensure the file paths are in your system directory.
https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html#Search-Path -
March 23rd, 2016 9:48 PMjiangzhengwenjzwOh, i forgot to ask. As you know, there're many useful header files in the directory \devkitPro\libgba\include.
I want to know how to include them (for example, gba.h) in my project? (I've tried to use #include <gba.h>, but it didn't work. ) -
March 23rd, 2016 5:34 AMjiangzhengwenjzwok, ok, i know.
Thank you for your help! -
March 23rd, 2016 5:27 AMBlahAny local variable will be created in the stack, or a register would be used instead.
Try this:
u8 i = 5;
set_attr (pokemon, attr_HP, &i);
"i" would be created in the stack, and the SP would be passed into set_attr.
In almost all situations, programming in C is superior to programming in ASM. However, I should note that the ASM instructions generated by GCC/DevkitARM/whatever_you're_using, will always not be as efficient as hand written ASM will be. A competent human writing ASM will, in some cases, write code more efficiently than the compiler generated code. However, the benefits of writing the exact code in ASM isn't exactly worth it. Consider this: Would you rather spend 10 mins writing C code which executes 100 CPU cycles slower? Or spend 30 minutes writing ASM code which executes 100 CPU cycles faster? 100 CPU cycles is very negligible depending on the nature of your code and where it's used. In 99% of cases, we wouldn't care about the slight efficiency drop. The GBA's processor has a clock speed of 16.78Mhz. That means every second it has the potential to do 16780000 cpu cycles. Saving 100 cycles and spending 20 minutes does absolutely nothing. Something like this would only matter in an area like the main loop, which is executed extremely frequently.

