Gamebuino Classic vs. META compatibility and detection?

General

ishotjr

3 months ago

Apologies if this is already answered elsewhere - just starting to learn my way around the new forums/docs/etc.; is there a way to support both platforms easily with the same codebase, e.g. an `#ifdef GB_META` or something that you can wrap around META-specific code blocks etc.?  In general, how compatible are the new and old API?  Thanks! :)

ishotjr

NEW 3 months ago

Update: here's my dirty hack for now:


```

#ifdef GB_META
#include <Gamebuino-Meta.h>

// this is a silly way to get quick META compatibility for now
#define LCDWIDTH gb.display.width()
#define LCDHEIGHT gb.display.height()
#define BTN_UP BUTTON_UP
#define BTN_DOWN BUTTON_DOWN
#define BTN_A BUTTON_A
#define BTN_C BUTTON_MENU

#else
#include <Gamebuino.h>
Gamebuino gb;
#endif

```

Plus


```

#ifdef GB_META
    // META requires explicit clear at beginning of loop
    gb.display.clear();
#endif

```


and:


```

#ifndef GB_META
  // CLASSIC only
 
  // remember to use F() for strings in order to save RAM!
  gb.titleScreen(F("Obsidian"));
#endif

```


:)

jicehel

NEW 3 months ago

Your idea is to make prog compatible for both and that, no it's not aleady a subject on the forum but its a good idea. Else the existing subject is how to convert a game from classic to META (other way don't exist yet on forum); https://gamebuino.com/fr/creations/port-games-from-classic-to-meta

ishotjr

3 months ago

Thanks, I was not aware of that thread; this appears to be pretty much exactly what I ended up hacking in above! :)


https://github.com/Gamebuino/Gamebuino-Compat/blob/master/src/Gamebuino-Compat.h#L52

ishotjr

NEW 3 months ago

jicehel jicehel

Thanks, I was not aware of that thread; this appears to be pretty much exactly what I ended up hacking in above! :)


https://github.com/Gamebuino/Gamebuino-Compat/blob/master/src/Gamebuino-Compat.h#L52

jicehel

NEW 3 months ago

Cool  ;)  Yes if it's for that it's alot easier with that  ;)

You must be logged in in order to post a message on the forum

Log in