Conversation Between jiangzhengwenjzw and Blah
46 to 60 of 89
  1. Blah
    March 26th, 2016 5:31 AM
    Blah
    yeah this works. Try it
  2. jiangzhengwenjzw
    March 26th, 2016 5:21 AM
    jiangzhengwenjzw
    I think I do exactly what you said, but it doesn't work lol
    Have you yourself tried this way to compile?
  3. Blah
    March 26th, 2016 5:17 AM
    Blah
    extern void func_2();

    void func_1() { func_2();}

    ---

    void func_2() {}
  4. jiangzhengwenjzw
    March 26th, 2016 5:10 AM
    jiangzhengwenjzw
    I don't understand. Would you mind showing me an example?
  5. Blah
    March 26th, 2016 5:03 AM
    Blah
    extern does work in devkitarm. Devkitarm is based off of GCC.
    extern the entire function header.
  6. jiangzhengwenjzw
    March 26th, 2016 4:34 AM
    jiangzhengwenjzw
    Yes, 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.
  7. Blah
    March 26th, 2016 4:23 AM
    Blah
    Extern 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?
  8. jiangzhengwenjzw
    March 26th, 2016 4:08 AM
    jiangzhengwenjzw
    OK, 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.
  9. jiangzhengwenjzw
    March 24th, 2016 3:47 PM
    jiangzhengwenjzw
    ok. I think that's the simplest way haha
  10. Blah
    March 24th, 2016 7:57 AM
    Blah
    just copy it over, and change the "<>" to just normal double quotes :)
  11. jiangzhengwenjzw
    March 24th, 2016 7:34 AM
    jiangzhengwenjzw
    I 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
  12. Blah
    March 24th, 2016 4:38 AM
    Blah
    You 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
  13. jiangzhengwenjzw
    March 23rd, 2016 9:48 PM
    jiangzhengwenjzw
    Oh, 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. )
  14. jiangzhengwenjzw
    March 23rd, 2016 5:34 AM
    jiangzhengwenjzw
    ok, ok, i know.
    Thank you for your help!
  15. Blah
    March 23rd, 2016 5:27 AM
    Blah
    Any 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.