Skip to content

Commit

Permalink
Add FunKey S / Q36 Mini / RG Nano build
Browse files Browse the repository at this point in the history
  • Loading branch information
bardeci authored Dec 3, 2023
1 parent b333155 commit b88165e
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 37 deletions.
100 changes: 100 additions & 0 deletions Makefile.funkeys
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
CHAINPREFIX=/opt/FunKey-sdk-2.0.0
CROSS_COMPILE=$(CHAINPREFIX)/bin/arm-funkey-linux-musleabihf-

CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
SYSROOT := $(CHAINPREFIX)/arm-funkey-linux-musleabihf/sysroot
SDL_CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags)

OUTPUTNAME = gambatte-dms.funkeys

DEFINES = -DHAVE_STDINT_H -DVERSION_FUNKEYS -DROM_BROWSER
INCLUDES = -Isrc/gambatte_sdl -Ilibgambatte -Icommon -Iinclude -Ilibgambatte/include -Ilibgambatte/src $(SDL_CFLAGS)
OPT_FLAGS = -Ofast -fdata-sections -fdata-sections -fno-common -fno-PIC -flto
EXTRA_LDFLAGS = -lasound -lmikmod -Wl,--as-needed -Wl,--gc-sections -flto -s

CFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu11
CXXFLAGS = $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -std=gnu++11
LDFLAGS = -Wl,--start-group -lSDL -lSDL_image -lpng -ljpeg -lSDL_mixer -logg -lvorbisidec -lmikmod -lm -pthread -lz -lstdc++ $(EXTRA_LDFLAGS) -Wl,--end-group

# Redream (main engine)
OBJS = \
libgambatte/src/bitmap_font.o \
libgambatte/src/bootloader.o \
libgambatte/src/cpu.o \
libgambatte/src/gambatte.o \
libgambatte/src/initstate.o \
libgambatte/src/interrupter.o \
libgambatte/src/interruptrequester.o \
libgambatte/src/loadres.o \
libgambatte/src/memory.o \
libgambatte/src/sound.o \
libgambatte/src/state_osd_elements.o \
libgambatte/src/statesaver.o \
libgambatte/src/tima.o \
libgambatte/src/video.o \
libgambatte/src/mem/cartridge.o \
libgambatte/src/mem/memptrs.o \
libgambatte/src/mem/pakinfo.o \
libgambatte/src/mem/rtc.o \
libgambatte/src/sound/channel1.o \
libgambatte/src/sound/channel2.o \
libgambatte/src/sound/channel3.o \
libgambatte/src/sound/channel4.o \
libgambatte/src/sound/duty_unit.o \
libgambatte/src/sound/envelope_unit.o \
libgambatte/src/sound/length_counter.o \
libgambatte/src/video/ly_counter.o \
libgambatte/src/video/lyc_irq.o \
libgambatte/src/video/next_m0_time.o \
libgambatte/src/video/ppu.o \
libgambatte/src/video/sprite_mapper.o

ifeq ($(NOZIP), YES)
OBJS += libgambatte/src/file/file.o
else
OBJS += libgambatte/src/file/file_zip.o libgambatte/src/file/unzip/ioapi.o libgambatte/src/file/unzip/unzip.o
endif

OBJS += gambatte_sdl/src/audiosink.o \
gambatte_sdl/src/blitterwrapper.o \
gambatte_sdl/src/parser.o \
gambatte_sdl/src/sdlblitter.o \
gambatte_sdl/src/str_to_sdlkey.o \
gambatte_sdl/src/usec.o \
gambatte_sdl/src/gambatte_sdl.o \
gambatte_sdl/SFont.o \
gambatte_sdl/menu.o \
gambatte_sdl/libmenu.o \
gambatte_sdl/scaler.o \
common/adaptivesleep.o \
common/resample/src/chainresampler.o \
common/resample/src/i0.o \
common/resample/src/kaiser50sinc.o \
common/resample/src/kaiser70sinc.o \
common/resample/src/makesinckernel.o \
common/resample/src/resamplerinfo.o \
common/resample/src/u48div.o \
common/rateest.o \
common/skipsched.o \
common/videolink/rgb32conv.o \
common/videolink/vfilterinfo.o

.c.o:
$(CC) $(CFLAGS) -c -o $@ $<

.cpp.o:
$(CXX) $(CXXFLAGS) -c -o $@ $<

all: executable

gambatte_sdl/menu.o: builddate

builddate:
echo "#define BUILDDATE \"$$(date +'%Y%m%d-%H%M%S')"\" > ./gambatte_sdl/builddate.h

executable: $(OBJS)
$(CC) -o $(OUTPUTNAME) $(OBJS) $(CFLAGS) $(LDFLAGS)

clean:
rm $(OBJS) $(OUTPUTNAME)
10 changes: 10 additions & 0 deletions build_funkeys_opk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

BDAT=$(date +"%Y%m%d-%H%M%S")
echo '#define BUILDDATE "'$BDAT'"' >./gambatte_sdl/builddate.h

make -f Makefile.funkeys
BDAT=$(date +"%Y%m%d")
rm -f gambatte-dms-funkey-s-r572u4-$BDAT.opk
mksquashfs ./dist/funkeys/default.funkey-s.desktop gambatte-dms.funkeys ./dist/gambatte_dms.png ./dist/manual.txt gambatte-dms-funkey-s-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports
make -f Makefile.funkeys clean
6 changes: 6 additions & 0 deletions dist/funkeys/default.funkey-s.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Name=Gambatte-DMS
Comment=GB/GBC emulator
Icon=gambatte_dms
Exec=gambatte-dms.funkeys
Categories=emulators
4 changes: 3 additions & 1 deletion dist/manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ autosave/autoload feature when enabled.
Emulator Options
------------------------------------------------

Here is a list of the available config options:
Here is a list of the available config options
(Note that some options may be unavailable on
some devices):

- Show FPS:
Shows or hides the FPS counter.
Expand Down
2 changes: 1 addition & 1 deletion gambatte_sdl/builddate.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILDDATE "20210731-123313"
#define BUILDDATE "20231203-020959"
25 changes: 24 additions & 1 deletion gambatte_sdl/libmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ Mix_Chunk *menusound_ok = NULL;
int showfps = 0, ghosting = 1, biosenabled = 0, colorfilter = 0, gameiscgb = 0, buttonlayout = 0, stereosound = 1, prefercgb = 1, ffwhotkey = 1, stateautoload = 0, stateautosave = 0;
uint32_t menupalblack = 0x000000, menupaldark = 0x505450, menupallight = 0xA8A8A8, menupalwhite = 0xF8FCF8;
int filtervalue[12] = {135, 20, 0, 25, 0, 125, 20, 25, 0, 20, 105, 30};
#ifndef VERSION_FUNKEYS
std::string selectedscaler= "No Scaling", dmgbordername = "DEFAULT", gbcbordername = "DEFAULT", palname = "DEFAULT", filtername = "NONE", currgamename = "default";
#else
std::string selectedscaler= "1.5x Smooth", dmgbordername = "NONE", gbcbordername = "NONE", palname = "DEFAULT", filtername = "NONE", currgamename = "default";
#endif
std::string homedir = getenv("HOME");
std::string ipuscaling = "NONE";
int numcodes_gg = NUM_GG_CODES, numcodes_gs = NUM_GS_CODES, selectedcode = 0, editmode = 0, blink = 0, footer_alt = 0;
Expand Down Expand Up @@ -268,7 +272,7 @@ void openMenuAudio(){
#elif defined VERSION_BITTBOY || defined VERSION_POCKETGO
Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024);
#else
Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1792);
Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024);
#endif
Mix_AllocateChannels(2);
}
Expand Down Expand Up @@ -351,27 +355,31 @@ void clean_menu_screen(menu_t *menu){
* opendingux pre-release hardware surfaces bug */
clear_surface(screen, 0);
redraw(menu);
#ifndef VERSION_FUNKEYS
//SDL_Flip(screen);
clear_surface(screen, 0);
redraw(menu); // redraw function also flips the screen. delete and restore sdl_flip if problematic
//SDL_Flip(screen);
clear_surface(screen, 0);
redraw(menu); // this third one is for triple-buffer
//SDL_Flip(screen);
#endif
}

void clean_menu_screen_cheat(menu_t *menu){
/* doing this twice is just an ugly hack to get round an
* opendingux pre-release hardware surfaces bug */
clear_surface(screen, 0);
redraw_cheat(menu);
#ifndef VERSION_FUNKEYS
//SDL_Flip(screen);
clear_surface(screen, 0);
redraw_cheat(menu); // redraw function also flips the screen. delete and restore sdl_flip if problematic
//SDL_Flip(screen);
clear_surface(screen, 0);
redraw_cheat(menu); // this third one is for triple-buffer
//SDL_Flip(screen);
#endif
}

void menu_message(menu_t *menu) {
Expand Down Expand Up @@ -528,6 +536,7 @@ int menu_main(menu_t *menu) {
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
case SDLK_UP:
case SDLK_u:
if(num_selectable > 0){
playMenuSound_move();
}
Expand All @@ -544,6 +553,7 @@ int menu_main(menu_t *menu) {
textanim_reset();
break;
case SDLK_DOWN:
case SDLK_d:
if(num_selectable > 0){
playMenuSound_move();
}
Expand All @@ -560,6 +570,7 @@ int menu_main(menu_t *menu) {
textanim_reset();
break;
case SDLK_LEFT:
case SDLK_l:
if (menu->entries[menu->selected_entry]->is_shiftable) {
if (menu->entries[menu->selected_entry]->selected_entry > 0) {
--menu->entries[menu->selected_entry]->selected_entry;
Expand Down Expand Up @@ -588,6 +599,7 @@ int menu_main(menu_t *menu) {
}
break;
case SDLK_RIGHT:
case SDLK_r:
if (menu->entries[menu->selected_entry]->is_shiftable) {
if (menu->entries[menu->selected_entry]->selected_entry < menu->entries[menu->selected_entry]->n_entries - 1) {
++menu->entries[menu->selected_entry]->selected_entry;
Expand Down Expand Up @@ -741,6 +753,7 @@ int menu_cheat(menu_t *menu) {
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
case SDLK_LEFT:
case SDLK_l:
playMenuSound_move();
if (editmode == 0){
if (collimit == 10){ // gameshark
Expand All @@ -766,6 +779,7 @@ int menu_cheat(menu_t *menu) {
dirty = 1;
break;
case SDLK_RIGHT:
case SDLK_r:
playMenuSound_move();
if (editmode == 0){
if (collimit == 10){ // gameshark
Expand All @@ -791,6 +805,7 @@ int menu_cheat(menu_t *menu) {
dirty = 1;
break;
case SDLK_UP:
case SDLK_u:
playMenuSound_move();
if (editmode == 0){
for (i = 0; i < collimit; i++) { // go up 1 line
Expand All @@ -814,6 +829,7 @@ int menu_cheat(menu_t *menu) {
dirty = 1;
break;
case SDLK_DOWN:
case SDLK_d:
playMenuSound_move();
if (editmode == 0){
for (i = 0; i < collimit; i++) { // go down 1 line
Expand Down Expand Up @@ -854,6 +870,7 @@ int menu_cheat(menu_t *menu) {
dirty = 1;
break;
case SDLK_RETURN: // start button - Apply
case SDLK_s:
if (collimit == 11){ // if gamegenie
if (menu->entries[menu->n_entries -1]->callback != NULL) {
menu->entries[menu->n_entries -1]->callback(menu);
Expand Down Expand Up @@ -1937,7 +1954,9 @@ static void redraw(menu_t *menu) {
clear_surface(screen, 0x000000);
paint_border(screen);
} else { //if border image is disabled
#ifndef VERSION_FUNKEYS
clear_surface(screen, 0x000000);
#endif
}
display_menu(menuscreen, menu);
blitter_p->scaleMenu();
Expand All @@ -1964,7 +1983,9 @@ static void redraw_blank(menu_t *menu) {
display_menu(menuscreen, menu);
SDL_FillRect(menuscreen, &rect, convert_hexcolor(screen, 0xFFFFFF));
} else { //if border image is disabled
#ifndef VERSION_FUNKEYS
clear_surface(screen, 0x000000);
#endif
display_menu(menuscreen, menu);
SDL_FillRect(menuscreen, &rect, convert_hexcolor(screen, 0xFFFFFF));
}
Expand All @@ -1983,7 +2004,9 @@ static void redraw_cheat(menu_t *menu) {
clear_surface(screen, 0x000000);
paint_border(screen);
} else { //if border image is disabled
#ifndef VERSION_FUNKEYS
clear_surface(screen, 0x000000);
#endif
}
display_menu_cheat(menuscreen, menu);
blitter_p->scaleMenu();
Expand Down
10 changes: 10 additions & 0 deletions gambatte_sdl/libmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ extern "C" {
#define KEYMAP_MENUCANCEL SDLK_LCTRL
#define KEYMAP_MENUACCEPT SDLK_LALT

#elif defined VERSION_FUNKEYS

#define BLINK_SPEED 24
#define FOOTER_ALT_SPEED 192
#define TEXTANIM_DELAY 128
#define TEXTANIM_SPEED 13

#define KEYMAP_MENUCANCEL SDLK_b
#define KEYMAP_MENUACCEPT SDLK_a

#else

#define BLINK_SPEED 12
Expand Down
Loading

0 comments on commit b88165e

Please sign in to comment.