Skip to content

Commit

Permalink
build, odbeta and opendingux cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Dec 5, 2023
1 parent 8a9b632 commit b9badeb
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ jobs:
run: |
git config --global --add safe.directory $PWD
ver=$(cut -d'"' -f2 platform/common/version.h)-$(git rev-parse --short HEAD)
./configure --platform=gcw0 --platform=odbeta
./configure --platform=odbeta
make -j2
mv PicoDrive.opk PicoDrive-odbeta-gcw0-$ver.opk
- name: artifacts
Expand All @@ -230,7 +230,7 @@ jobs:
run: |
git config --global --add safe.directory $PWD
ver=$(cut -d'"' -f2 platform/common/version.h)-$(git rev-parse --short HEAD)
./configure --platform=opendingux --platform=odbeta
./configure --platform=odbeta
make -j2
mv PicoDrive.opk PicoDrive-odbeta-lepus-$ver.opk
- name: artifacts
Expand All @@ -250,7 +250,7 @@ jobs:
run: |
git config --global --add safe.directory $PWD
ver=$(cut -d'"' -f2 platform/common/version.h)-$(git rev-parse --short HEAD)
./configure --platform=opendingux --platform=odbeta
./configure --platform=odbeta
make -j2
mv PicoDrive.opk PicoDrive-odbeta-rg99-$ver.opk
- name: artifacts
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ifneq ($(call chkCCflag, -fipa-ra),) # gcc >= 5
CFLAGS += $(call chkCCflag, -flto -fipa-pta -fipa-ra)
else
# these improve execution speed on 32bit arm/mips with gcc pre-5 toolchains
CFLAGS += -fno-caller-saves -fno-guess-branch-probability -fno-regmove
CFLAGS += $(call chkCCflag, -fno-caller-saves -fno-guess-branch-probability -fno-regmove)
# very old gcc toolchains may not have these options
CFLAGS += $(call chkCCflag, -fno-tree-loop-if-convert -fipa-pta -fno-ipa-cp)
endif
Expand Down
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ set_platform()
;;
odbeta)
# various devices with opendingux beta, arch flags from toolchain default
sound_drivers="sdl"
CFLAGS="$CFLAGS -D__OPENDINGUX__"
MFLAGS="" # toolchains are arch specific
platform="opendingux"
Expand Down
1 change: 1 addition & 0 deletions platform/common/emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ typedef struct _currentConfig_t {

extern currentConfig_t currentConfig, defaultConfig;
extern const char *PicoConfigFile;
extern const char *PicoDevice;
extern int state_slot;
extern int config_slot, config_slot_current;
extern unsigned char *movie_data;
Expand Down
12 changes: 9 additions & 3 deletions platform/common/inputmap_kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const struct in_default_bind in_sdl_defbinds[] = {
{ 0, 0, 0 }
};

const struct menu_keymap in_sdl_key_map[] = {
const struct menu_keymap _in_sdl_key_map[] = {
{ SDLK_UP, PBTN_UP },
{ SDLK_DOWN, PBTN_DOWN },
{ SDLK_LEFT, PBTN_LEFT },
Expand All @@ -46,8 +46,9 @@ const struct menu_keymap in_sdl_key_map[] = {
{ SDLK_BACKSPACE, PBTN_L },
};
const int in_sdl_key_map_sz = sizeof(in_sdl_key_map) / sizeof(in_sdl_key_map[0]);
const struct menu_keymap *in_sdl_key_map = _in_sdl_key_map;

const struct menu_keymap in_sdl_joy_map[] = {
const struct menu_keymap _in_sdl_joy_map[] = {
{ SDLK_UP, PBTN_UP },
{ SDLK_DOWN, PBTN_DOWN },
{ SDLK_LEFT, PBTN_LEFT },
Expand All @@ -59,5 +60,10 @@ const struct menu_keymap in_sdl_joy_map[] = {
{ SDLK_WORLD_3, PBTN_MA3 },
};
const int in_sdl_joy_map_sz = sizeof(in_sdl_joy_map) / sizeof(in_sdl_joy_map[0]);
const struct menu_keymap *in_sdl_joy_map = _in_sdl_joy_map;

const char * const (*in_sdl_key_names)[SDLK_LAST] = NULL;
const char * const *in_sdl_key_names = NULL;

void plat_sdl_initkeys(void)
{
}
26 changes: 21 additions & 5 deletions platform/common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
static int load_state_slot = -1;
char **g_argv;

#if defined __MIYOO__
const char *PicoDevice = "miyoo";
#elif defined __GCW0__
const char *PicoDevice = "gcw0";
#elif defined __RETROFW__
const char *PicoDevice = "retrofw";
#elif defined __DINGUX__
const char *PicoDevice = "dingux";
#elif defined __OPENDINGUX__
const char *PicoDevice = "opendingux";
#else
const char *PicoDevice = "";
#endif

void parse_cmd_line(int argc, char *argv[])
{
int x, unrecognized = 0;
Expand All @@ -40,6 +54,9 @@ void parse_cmd_line(int argc, char *argv[])
{
if (x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
}
else if (strncasecmp(argv[x], "-device=", 8) == 0) {
PicoDevice = strdup(argv[x] + 8);
}
else if (strcasecmp(argv[x], "-pdb") == 0) {
if (x+1 < argc) { ++x; pdb_command(argv[x]); }
}
Expand All @@ -55,7 +72,6 @@ void parse_cmd_line(int argc, char *argv[])
if (f) {
fclose(f);
rom_fname_reload = argv[x];
engineState = PGS_ReloadRom;
}
else
unrecognized = 1;
Expand Down Expand Up @@ -84,6 +100,9 @@ int main(int argc, char *argv[])
//in_probe();

plat_target_init();
if (argc > 1)
parse_cmd_line(argc, argv);

plat_init();
menu_init();

Expand All @@ -92,12 +111,9 @@ int main(int argc, char *argv[])

emu_init();

engineState = PGS_Menu;
engineState = rom_fname_reload ? PGS_ReloadRom : PGS_Menu;
plat_video_menu_enter(0);

if (argc > 1)
parse_cmd_line(argc, argv);

if (engineState == PGS_ReloadRom)
{
plat_video_menu_begin();
Expand Down
7 changes: 4 additions & 3 deletions platform/common/plat_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ static struct area { int w, h; } area;

static struct in_pdata in_sdl_platform_data = {
.defbinds = in_sdl_defbinds,
.key_map = in_sdl_key_map,
.joy_map = in_sdl_joy_map,
};

/* YUV stuff */
Expand Down Expand Up @@ -392,9 +390,12 @@ void plat_init(void)
g_screen_ppitch = 320;
g_screen_ptr = shadow_fb;

plat_sdl_initkeys();
in_sdl_platform_data.kmap_size = in_sdl_key_map_sz,
in_sdl_platform_data.key_map = in_sdl_key_map,
in_sdl_platform_data.jmap_size = in_sdl_joy_map_sz,
in_sdl_platform_data.key_names = *in_sdl_key_names,
in_sdl_platform_data.joy_map = in_sdl_joy_map,
in_sdl_platform_data.key_names = in_sdl_key_names,
in_sdl_init(&in_sdl_platform_data, plat_sdl_event_handler);
in_probe();

Expand Down
7 changes: 4 additions & 3 deletions platform/common/plat_sdl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

extern const struct in_default_bind in_sdl_defbinds[];
extern const struct menu_keymap in_sdl_key_map[];
extern const struct menu_keymap *in_sdl_key_map;
extern const int in_sdl_key_map_sz;
extern const struct menu_keymap in_sdl_joy_map[];
extern const struct menu_keymap *in_sdl_joy_map;
extern const int in_sdl_joy_map_sz;
extern const char * const (*in_sdl_key_names)[SDLK_LAST];
extern const char * const *in_sdl_key_names;
extern void plat_sdl_initkeys(void);
101 changes: 66 additions & 35 deletions platform/opendingux/inputmap.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL_keysym.h>

#include "../libpicofe/input.h"
#include "../libpicofe/in_sdl.h"
#include "../common/input_pico.h"
#include "../common/plat_sdl.h"
#include "../common/emu.h"

const struct in_default_bind in_sdl_defbinds[] = {
{ SDLK_UP, IN_BINDTYPE_PLAYER12, GBTN_UP },
Expand All @@ -24,26 +27,22 @@ const struct in_default_bind in_sdl_defbinds[] = {
{ 0, 0, 0 }
};

const struct menu_keymap in_sdl_key_map[] = {
struct menu_keymap _in_sdl_key_map[] = {
{ SDLK_UP, PBTN_UP },
{ SDLK_DOWN, PBTN_DOWN },
{ SDLK_LEFT, PBTN_LEFT },
{ SDLK_RIGHT, PBTN_RIGHT },
#if defined(__MIYOO__)
{ SDLK_LALT, PBTN_MOK },
{ SDLK_LCTRL, PBTN_MBACK },
#else
{ SDLK_LCTRL, PBTN_MOK },
{ SDLK_LALT, PBTN_MBACK },
#endif
{ SDLK_SPACE, PBTN_MA2 },
{ SDLK_LSHIFT, PBTN_MA3 },
{ SDLK_TAB, PBTN_L },
{ SDLK_BACKSPACE, PBTN_R },
};
const int in_sdl_key_map_sz = sizeof(in_sdl_key_map) / sizeof(in_sdl_key_map[0]);
const int in_sdl_key_map_sz = sizeof(_in_sdl_key_map) / sizeof(_in_sdl_key_map[0]);
const struct menu_keymap *in_sdl_key_map = _in_sdl_key_map;

const struct menu_keymap in_sdl_joy_map[] = {
const struct menu_keymap _in_sdl_joy_map[] = {
{ SDLK_UP, PBTN_UP },
{ SDLK_DOWN, PBTN_DOWN },
{ SDLK_LEFT, PBTN_LEFT },
Expand All @@ -54,49 +53,81 @@ const struct menu_keymap in_sdl_joy_map[] = {
{ SDLK_WORLD_2, PBTN_MA2 },
{ SDLK_WORLD_3, PBTN_MA3 },
};
const int in_sdl_joy_map_sz = sizeof(in_sdl_joy_map) / sizeof(in_sdl_joy_map[0]);
const int in_sdl_joy_map_sz = sizeof(_in_sdl_joy_map) / sizeof(_in_sdl_joy_map[0]);
const struct menu_keymap *in_sdl_joy_map = _in_sdl_joy_map;

const char * const _in_sdl_key_names[SDLK_LAST] = {
const char * _in_sdl_key_names[SDLK_LAST] = {
/* common */
[SDLK_UP] = "UP",
[SDLK_DOWN] = "DOWN",
[SDLK_LEFT] = "LEFT",
[SDLK_RIGHT] = "RIGHT",
#if defined(__MIYOO__)
[SDLK_LALT] = "A",
[SDLK_LCTRL] = "B",
#else
[SDLK_LCTRL] = "A",
[SDLK_LALT] = "B",
#endif
#if defined(__GCW0__) || defined(__MIYOO__)
[SDLK_LSHIFT] = "X",
[SDLK_SPACE] = "Y",
#else
[SDLK_LSHIFT] = "Y",
[SDLK_SPACE] = "X",
#endif
[SDLK_RETURN] = "START",
[SDLK_ESCAPE] = "SELECT",

#if defined(__MIYOO__)
[SDLK_TAB] = "L1",
[SDLK_BACKSPACE] = "R1",
[SDLK_RALT] = "L2",
[SDLK_RSHIFT] = "R2",
[SDLK_RCTRL] = "RESET",
#elif defined(__GCW0__) || defined(__DINGUX__) || defined(__RETROFW__)
[SDLK_TAB] = "L",
[SDLK_BACKSPACE] = "R",
[SDLK_POWER] = "POWER",
[SDLK_PAUSE] = "LOCK",
#else
[SDLK_TAB] = "L1",
[SDLK_BACKSPACE] = "R1",

/* opendingux rg, gkd etc */
[SDLK_PAGEUP] = "L2",
[SDLK_PAGEDOWN] = "R2",
[SDLK_KP_DIVIDE] = "L3",
[SDLK_KP_PERIOD] = "R3",
[SDLK_HOME] = "POWER",
#endif
/* gcw0 */
[SDLK_POWER] = "POWER",
[SDLK_PAUSE] = "LOCK",
/* miyoo */
[SDLK_RALT] = "L2",
[SDLK_RSHIFT] = "R2",
[SDLK_RCTRL] = "RESET",
};
const char * const (*in_sdl_key_names)[SDLK_LAST] = &_in_sdl_key_names;
const char * const *in_sdl_key_names = _in_sdl_key_names;


static void nameset(int x1, const char *name)
{
_in_sdl_key_names[x1] = name;
}

static void nameswap(int x1, int x2)
{
const char **p = &_in_sdl_key_names[x1];
const char **q = &_in_sdl_key_names[x2];
const char *t = *p; *p = *q; *q = t;
}

static void keyswap(int k1, int k2)
{
int x1, x2, t;

for (x1 = in_sdl_key_map_sz-1; x1 >= 0; x1--)
if (_in_sdl_key_map[x1].key == k1) break;
for (x2 = in_sdl_key_map_sz-1; x2 >= 0; x2--)
if (_in_sdl_key_map[x2].key == k2) break;
if (x1 >= 0 && x2 >= 0) {
struct menu_keymap *p = &_in_sdl_key_map[x1];
struct menu_keymap *q = &_in_sdl_key_map[x2];
t = p->pbtn; p->pbtn = q->pbtn; q->pbtn = t;
}
}

void plat_sdl_initkeys(void)
{
if (strcmp(PicoDevice, "miyoo") == 0) {
/* swapped A/B and X/Y keys */
keyswap(SDLK_LALT, SDLK_LCTRL);
nameswap(SDLK_LALT, SDLK_LCTRL);
nameswap(SDLK_SPACE, SDLK_LSHIFT);
} else if (strcmp(PicoDevice, "gcw0") == 0) {
/* swapped X/Y keys, single L/R keys */
nameswap(SDLK_SPACE, SDLK_LSHIFT);
nameset(SDLK_TAB, "L"); nameset(SDLK_BACKSPACE, "R");
} else if (strcmp(PicoDevice, "retrofw") == 0 || strcmp(PicoDevice, "dingux") == 0) {
/* single L/R keys */
nameset(SDLK_TAB, "L"); nameset(SDLK_BACKSPACE, "R");
}
}
12 changes: 6 additions & 6 deletions tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,30 @@ mv PicoDrive-pandora-$rel release-$rel/
}

[ -z "${plat##* odbeta-gcw0 *}" ] && {
# gcw0 (untested): JZ4770 (mips32r2 with fpu), swapped X/Y buttons
# gcw0, rg350 and similar devices: JZ4770 (mips32r2 with fpu)
docker pull ghcr.io/irixxxx/toolchain-odbeta-gcw0
echo " git config --global --add safe.directory /home/picodrive &&\
./configure --platform=gcw0 --platform=odbeta &&\
./configure --platform=odbeta &&\
make clean && make -j2 all "\
| docker run -i -v$PWD:/home/picodrive -w/home/picodrive --rm ghcr.io/irixxxx/toolchain-odbeta-gcw0 sh &&
mv PicoDrive.opk release-$rel/PicoDrive-odbeta-gcw0_$rel.opk
}

[ -z "${plat##* odbeta-lepus *}" ] && {
# rg300 and other Ingenic lepus based (untested): JZ4760 (mips32r1 with fpu)
# rg300 and other Ingenic lepus based: JZ4760 (mips32r1 with fpu)
docker pull ghcr.io/irixxxx/toolchain-odbeta-lepus
echo " git config --global --add safe.directory /home/picodrive &&\
./configure --platform=opendingux --platform=odbeta &&\
./configure --platform=odbeta &&\
make clean && make -j2 all "\
| docker run -i -v$PWD:/home/picodrive -w/home/picodrive --rm ghcr.io/irixxxx/toolchain-odbeta-lepus sh &&
mv PicoDrive.opk release-$rel/PicoDrive-odbeta-lepus_$rel.opk
}

[ -z "${plat##* odbeta-rg99 *}" ] && {
# rg99 and other JZ4725B based (untested): JZ4760 (mips32r1 w/o fpu)
# rg99 and similar devices: JZ4725B (mips32r1 w/o fpu)
docker pull ghcr.io/irixxxx/toolchain-odbeta-rs90
echo " git config --global --add safe.directory /home/picodrive &&\
./configure --platform=opendingux --platform=odbeta &&\
./configure --platform=odbeta &&\
make clean && make -j2 all "\
| docker run -i -v$PWD:/home/picodrive -w/home/picodrive --rm ghcr.io/irixxxx/toolchain-odbeta-rs90 sh &&
mv PicoDrive.opk release-$rel/PicoDrive-odbeta-rg99_$rel.opk
Expand Down

0 comments on commit b9badeb

Please sign in to comment.