MOD files

Previous topic - Next topic

x-tra

What i have to do using a gbas file as library?
As mod.

Only rightklick in right window in the file menu?

Or how i have zu insert this lib/mod/orwhatever?

Kitty Hello

right click in the file menu: Insert file, locate the file, press OK.
If it's in the file list, it will be compiled and used.

x-tra

like the entity sys in german forum from you?and after compiling the commands are available?

Schranz0r

You must not compile!

Lets see how it works:

If you have a couple of functions on a GBAS, and you include thisone to youre project(GBAP) , you can see all functions from the GBAS on the "Code-Completion"-Popup!
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

S.O.P.M.

No chance. I would really like to know what I still make wrong! Now, I have 2 files again. The first one (main program) contains exactly this:
Code (glbasic) Select
// --------------------------------- //
// Project: fmod_player
// Start: Tuesday, May 09, 2006
// IDE Version: 3.118

    snd$ = "rb_1.it"
    good = FMod_Load(snd$)

    FMod_Play()

WHILE TRUE
    PRINT "PLAY: "+snd$ + " returns: "+good, 100,100
    PRINT "IsFinished: " + FMod_IsFinished(), 100, 120
    PRINT "click mouse to stop", 100,140
    IF MOUSEAXIS(3) THEN BREAK
    SHOWSCREEN
WEND

    FMod_Stop()

FUNCTION end_main_foo:
ENDFUNCTION
the rest is in the other file:
Code (glbasic) Select
INLINE
    DECLARE_ALIAS(FMUSIC_LoadSong, "fmod.dll", "_FMUSIC_LoadSong@4", (const char* name), void*);
    DECLARE_ALIAS(FMUSIC_PlaySong, "fmod.dll", "_FMUSIC_PlaySong@4", (void* pMod), char);
    DECLARE_ALIAS(FMUSIC_FreeSong, "fmod.dll", "_FMUSIC_FreeSong@4", (void* pMod), char);
    DECLARE_ALIAS(FSOUND_Init, "fmod.dll", "_FSOUND_Init@12", (int, int, unsigned int), char);
    DECLARE_ALIAS(FSOUND_Close, "fmod.dll", "_FSOUND_Close@0", (void), void);
    DECLARE_ALIAS(FMUSIC_IsFinished, "fmod.dll", "_FMUSIC_IsFinished@4", (void* pMod), char);

    void* g_pFMod = 0;

    // need this for ESC-exits
    struct FMOD_killer    {~FMOD_killer() {IF (g_pFMod) FMod_Stop();}    } g_Fmod_killa;
ENDINLINE

FUNCTION FMod_Load: fname$
GLOBAL fmod_init
LOCAL good
    IF fmod_init = FALSE
        fmod_init=TRUE
    ENDIF

    FMod_Stop()
    INLINE

        if(FSOUND_Init) FSOUND_Init(44100,64,0);
        if(FMUSIC_LoadSong)
            g_pFMod = FMUSIC_LoadSong(fname_Str.c_str());
        if(g_pFMod) good = true;

    ENDINLINE
    RETURN good
ENDFUNCTION

FUNCTION FMod_Play:
    INLINE

        IF(FMUSIC_PlaySong && g_pFMod)
            FMUSIC_PlaySong(g_pFMod);

    ENDINLINE
ENDFUNCTION

FUNCTION FMod_Stop:
    INLINE

        IF(FMUSIC_FreeSong && g_pFMod)
            FMUSIC_FreeSong(g_pFMod);
        g_pFMod = 0;
        IF(FSOUND_Close)
            FSOUND_Close();
        fmod_init=FALSE;
    ENDINLINE
ENDFUNCTION

FUNCTION FMod_IsFinished:
    INLINE
        char ok=1;
        IF(FMUSIC_IsFinished && g_pFMod)
            ok = FMUSIC_IsFinished(g_pFMod);
        RETURN ok ? TRUE : FALSE;
    ENDINLINE

    RETURN TRUE
ENDFUNCTION
But I always get the "redefinition as different type - error". My understanding tells me that the error should be in the concerning line and nowhere else. Normally the inline stuff is for professionals only but in the case that the complete code is given - then I can't accept when it doesn't work. The only reason why this won't run could be the fact that I have only the 2D and NET feature, not the SDK premium.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

struct FMOD_killer    {~FMOD_killer() {IF (g_pFMod) FMod_Stop();}    } g_Fmod_killa;

The 'IF' became capital letters - might be a bug in the editor.
Same here:
        IF(FMUSIC_PlaySong && g_pFMod)

and here:
        IF(FSOUND_Close)
and here:
        IF(FMUSIC_IsFinished && g_pFMod)
            ok = FMUSIC_IsFinished(g_pFMod);
        RETURN ok ? TRUE : FALSE;


The RETURN is capitals, too. In C++ (INLINE) all commands must be small letters. Sorry.

S.O.P.M.

All commands inside the inline blocks are small letters now. To me every mint green colored word is a command so I changed also the "DECLARE_ALIAS" to small letters. But... oh no! Same error again.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

No, DECLARE_ALIAS must be capitals. You'd better copy the samples from the program's directory to your homepath again. The examples I shipped work.

S.O.P.M.

IMO this is very confusing! I have the feeling to be messed around and that there's something that I don't know! By the way, the gp2x cpu-clock sample doesn't work also. My compiler won't handle any inline s*. Am I really so stupid to be unable to do what anybody else tried successfully!? I am very sorry, Gernot, but this is a thing that makes me really angry.
Now I will copy the original samples...
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

inline usually is bad. If it doesn't work, however, it's not satisfying. I think the editor is messing with pasted code again. I'll check that out for you.

[edit]
Checked this out:
http://www.glbasic.com/forum/viewtopic.php?pid=6874#p6874
and it compiles fine for me on both, win32, and GP2X.
What errors do you get?

S.O.P.M.

Using the new copied sample doesn't make any difference so the problem isn't solved. What are the conditions GLBasic needs to compile C++ code correctly? Any special files in the windows system dir I don't have?
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

S.O.P.M.

QuoteChecked this out:
http://www.glbasic.com/forum/viewtopic. … 6874#p6874
and it compiles fine for me on both, win32, and GP2X.
What errors do you get?
I tried that and got "redefinition as different type". If this is really a bug in the editor then I wonder why it works fine for others.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

OK, please write down bit by bit what you did. Maybe your copy/paste differs from mine.

S.O.P.M.

Quite simple. I did all by mouse. At first I marked the code in the board's code view window by dragging the mouse over it, then the copy command from the context window (right mouse button). And in the GLBasic editor I did a right click in the text window and then 'Paste'. That's all I did.

...yes I know, with the Strg + A shortcut I would ensure that the entire code will marked.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

Kitty Hello

...and you only marked last thread's code-section. I don't say you're stupid, I just want to be very sure. The problem cannot be reproduced here. I'll try some more, though.