Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tracker/Makefile.miyooports
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# MiyooPorts makefile

# MiyooPorts platform identifier
PLATFORM = miyooports

include Makefile.common

# MiyooPorts-specific settings
LIBS = $(COMMON_LIBS) platforms/sdl12
OUTPUT_EXT =
DOCKER32 = docker run --privileged --platform=linux/armhf --rm --user $$(id -u):$$(id -g) -v`pwd`/..:/src -w/src/tracker

# MiyooPorts build settings
XTRA_CFLAGS = -DMIYOOPORTS_BUILD -I${SYSROOT}/usr/include -L${SYSROOT}/usr/lib
XTRA_LIBS = -lSDL -lm
CFLAGS = $(COMMON_CFLAGS) $(INCLUDES) $(SOURCES) $(XTRA_CFLAGS)

.PHONY: .MiyooPorts
.MiyooPorts:
mkdir -p $(BUILD)
$(CROSS_COMPILE)$(CC) $(CFLAGS) $(XTRA_LIBS) -o $(BUILD)/chipnomad.armhf
chmod +x $(BUILD)/chipnomad.armhf

.PHONY: MiyooPorts
MiyooPorts:
@./check-docker.sh || exit 1
$(DOCKER32) monkeyx/retro_builder:arm32 make -f Makefile.miyooports .MiyooPorts CC=gcc CPU=armhf

.PHONY: MiyooPorts-deploy
MiyooPorts-deploy: MiyooPorts
@echo "Creating MiyooPorts deployment package..."
@mkdir -p ../../releases
@rm -rf /tmp/chipnomad-miyooports-package
@mkdir -p /tmp/chipnomad-miyooports-package/Roms/PORTS/Games/ChipNomad
@mkdir -p /tmp/chipnomad-miyooports-package/Roms/PORTS/Imgs
@mkdir -p /tmp/chipnomad-miyooports-package/Roms/PORTS/Shortcuts/ChipNomad
@cp $(BUILD)/chipnomad.armhf /tmp/chipnomad-miyooports-package/Roms/PORTS/Games/ChipNomad/
@cp -r packaging/common/* /tmp/chipnomad-miyooports-package/Roms/PORTS/Games/ChipNomad/
@mv /tmp/chipnomad-miyooports-package/Roms/PORTS/Games/ChipNomad/chipnomad-icon.png /tmp/chipnomad-miyooports-package/Roms/PORTS/Imgs/ChipNomad.png
@cp -r packaging/miyoo_ports/* /tmp/chipnomad-miyooports-package/Roms/PORTS/Shortcuts/ChipNomad
$(eval VERSION := $(shell grep 'appVersion.*=' src/version.c | cut -d'"' -f2))
@cd /tmp/chipnomad-miyooports-package && zip -r ChipNomad-$$(date +%Y-%m-%d)-$(VERSION)-MiyooPorts.zip .
@mv /tmp/chipnomad-miyooports-package/ChipNomad-*-MiyooPorts.zip ../../releases/
@rm -rf /tmp/chipnomad-miyooports-package
@echo "MiyooPorts package created in ../../releases/"
4 changes: 4 additions & 0 deletions tracker/deploy-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ echo ""
echo "Building PortMaster release..."
make PortMaster-deploy

echo ""
echo "Building MiyooPorts release..."
make MiyooPorts-deploy

echo ""
echo "Building RG35xx release..."
make RG35xx-deploy
Expand Down
7 changes: 7 additions & 0 deletions tracker/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ RG35xx RG35xx-deploy:
PortMaster PortMaster-deploy:
$(MAKE) -f Makefile.portmaster $@

.PHONY: MiyooPorts MiyooPorts-deploy
MiyooPorts MiyooPorts-deploy:
$(MAKE) -f Makefile.miyooports $@

.PHONY: macOS macOS-deploy
macOS macOS-deploy:
$(MAKE) -f Makefile.macos $@
Expand Down Expand Up @@ -88,6 +92,9 @@ clean-rg35xx:
clean-portmaster:
rm -rf build/portmaster

clean-miyooports:
rm -rf build/miyoports

clean-macOS:
rm -rf build/macos

Expand Down
18 changes: 18 additions & 0 deletions tracker/packaging/miyoo_ports/ChipNomad.port
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
# Standalone Ports Script Template

# main configuration :
GameName="ChipNomad"
GameDir="ChipNomad"
GameExecutable="chipnomad.armhf"
GameDataFile=""

# additional configuration
KillAudioserver=0
PerformanceMode=0

# specific to this port :
Arguments=""

# running command line :
/mnt/SDCARD/Emu/PORTS/launch_standalone.sh "$GameName" "$GameDir" "$GameExecutable" "$Arguments" "$GameDataFile" "$KillAudioserver" "$PerformanceMode"
93 changes: 88 additions & 5 deletions tracker/platforms/sdl12/corelib_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,33 @@ static void createCharSurfaces(void) {
}
}

#ifdef MIYOOPORTS_BUILD
static SDL_Surface* offscreenSurface = NULL;
#endif

int gfxSetup(int *screenWidth, int *screenHeight) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
printf("SDL2 Initialization Error: %s\n", SDL_GetError());
#ifdef MIYOOPORTS_BUILD
sdlScreen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (!sdlScreen) {
printf("SDL1.2 Set Video Mode Error: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}

offscreenSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, WINDOW_WIDTH, WINDOW_HEIGHT, 32,
sdlScreen->format->Rmask, sdlScreen->format->Gmask, sdlScreen->format->Bmask, sdlScreen->format->Amask);
if (!offscreenSurface) {
printf("Failed to create offscreen surface: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
#else
sdlScreen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_HWSURFACE);
if (!sdlScreen) {
printf("SDL1.2 Set Video Mode Error: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
#endif

sprintf(charBuffer, "%s v%s (%s)", appTitle, appVersion, appBuild);
SDL_WM_SetCaption(charBuffer, NULL);
Expand All @@ -92,6 +107,12 @@ void gfxCleanup(void) {
if (charSurfaces[i]) SDL_FreeSurface(charSurfaces[i]);
}
SDL_FreeSurface(sdlScreen);
#ifdef MIYOOPORTS_BUILD
if (offscreenSurface) {
SDL_FreeSurface(offscreenSurface);
offscreenSurface = NULL;
}
#endif
}

void gfxSetFgColor(int rgb) {
Expand All @@ -116,18 +137,30 @@ void gfxSetCursorColor(int rgb) {
}

void gfxClear(void) {
#ifdef MIYOOPORTS_BUILD
SDL_FillRect(offscreenSurface, NULL, bgColor);
#else
SDL_FillRect(sdlScreen, NULL, bgColor);
#endif
isDirty = 1;
}

void gfxPoint(int x, int y, uint32_t color) {
#ifdef MIYOOPORTS_BUILD
((Uint32 *)offscreenSurface->pixels)[y * offscreenSurface->w + x] = color;
#else
((Uint32 *)sdlScreen->pixels)[y * sdlScreen->w + x] = color;
#endif
isDirty = 1;
}

void gfxClearRect(int x, int y, int w, int h) {
SDL_Rect rect = { CHAR_X(x), CHAR_Y(y), CHAR_X(w), CHAR_Y(h) };
#ifdef MIYOOPORTS_BUILD
SDL_FillRect(offscreenSurface, &rect, bgColor);
#else
SDL_FillRect(sdlScreen, &rect, bgColor);
#endif
isDirty = 1;
}

Expand All @@ -147,7 +180,11 @@ void gfxPrint(int x, int y, const char* text) {
continue;
}
SDL_Rect bgRect = {cx, cy, fontW * 8, fontH};
#ifdef MIYOOPORTS_BUILD
SDL_FillRect(offscreenSurface, &bgRect, bgColor);
#else
SDL_FillRect(sdlScreen, &bgRect, bgColor);
#endif
cx += fontW * 8;
if (cx > WINDOW_WIDTH) {
cx = CHAR_X(x);
Expand Down Expand Up @@ -179,7 +216,11 @@ void gfxPrint(int x, int y, const char* text) {
SDL_SetColors(charSurfaces[C - 32], colors, 0, 2);

SDL_Rect dstRect = {cx, cy, fontW * 8, fontH};
#ifdef MIYOOPORTS_BUILD
SDL_BlitSurface(charSurfaces[C - 32], NULL, offscreenSurface, &dstRect);
#else
SDL_BlitSurface(charSurfaces[C - 32], NULL, sdlScreen, &dstRect);
#endif
}

cx += fontW * 8;
Expand All @@ -201,7 +242,11 @@ void gfxPrintf(int x, int y, const char* format, ...) {

void gfxCursor(int x, int y, int w) {
SDL_Rect rect = { CHAR_X(x), CHAR_Y(y) + fontH - 1, CHAR_X(w), 1 };
#ifdef MIYOOPORTS_BUILD
SDL_FillRect(offscreenSurface, &rect, cursorColor);
#else
SDL_FillRect(sdlScreen, &rect, cursorColor);
#endif
isDirty = 1;
}

Expand All @@ -218,24 +263,61 @@ void gfxRect(int x, int y, int w, int h) {
{cx + cw - 1, cy, 1, ch} // right
};

#ifdef MIYOOPORTS_BUILD
for (int i = 0; i < 4; i++) {
SDL_FillRect(offscreenSurface, &rects[i], fgColor);
}
#else
for (int i = 0; i < 4; i++) {
SDL_FillRect(sdlScreen, &rects[i], fgColor);
}
#endif
isDirty = 1;
}

void gfxUpdateScreen(void) {
#ifdef MIYOOPORTS_BUILD
if (isDirty && offscreenSurface) {
SDL_LockSurface(offscreenSurface);
SDL_LockSurface(sdlScreen);
int w = offscreenSurface->w;
int h = offscreenSurface->h;
Uint32* src = (Uint32*)offscreenSurface->pixels;
Uint32* dst = (Uint32*)sdlScreen->pixels;
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
dst[(h - 1 - y) * w + (w - 1 - x)] = src[y * w + x];
}
}
SDL_UnlockSurface(offscreenSurface);
SDL_UnlockSurface(sdlScreen);
SDL_Flip(sdlScreen);
isDirty = 0;
}
#else
if (isDirty) {
SDL_UpdateRect(sdlScreen, 0, 0, 0, 0);
isDirty = 0;
}
isDirty = 0;
#endif
}

void gfxDrawCharBitmap(uint8_t* bitmap, int col, int row) {
int cx = CHAR_X(col);
int cy = CHAR_Y(row);
int charW = fontW * 8;

#ifdef MIYOOPORTS_BUILD
for (int y = 0; y < fontH; y++) {
for (int x = 0; x < charW; x++) {
uint8_t alpha = bitmap[y * charW + x];
uint8_t r = bgR + ((fgR - bgR) * alpha) / 255;
uint8_t g = bgG + ((fgG - bgG) * alpha) / 255;
uint8_t b = bgB + ((fgB - bgB) * alpha) / 255;
uint32_t color = SDL_MapRGB(offscreenSurface->format, r, g, b);
((Uint32 *)offscreenSurface->pixels)[(cy + y) * offscreenSurface->w + (cx + x)] = color;
}
}
#else
for (int y = 0; y < fontH; y++) {
for (int x = 0; x < charW; x++) {
uint8_t alpha = bitmap[y * charW + x];
Expand All @@ -246,6 +328,7 @@ void gfxDrawCharBitmap(uint8_t* bitmap, int col, int row) {
((Uint32 *)sdlScreen->pixels)[(cy + y) * sdlScreen->w + (cx + x)] = color;
}
}
#endif
isDirty = 1;
}

Expand Down