A lot of changes for speed up, code clean up, new release preparation and MorphOS code added

This commit is contained in:
George Sokianos 2022-09-19 19:29:41 +01:00
parent d7363ad95f
commit 2672b953a3
13 changed files with 239 additions and 84 deletions

View File

@ -22,7 +22,17 @@ It is recommended to have the following SDL2 options enabled at its prefs:
installed in your system
- Batching Mode: enabled
### Changelog
1.2.2r2 (2022-09-19)
* Did a few changes at the code that speeds up the game a lot
* Removed the white shadow from texts in some renderers
* Changed the freetype library with the latest version
* Removed the debug info at the start of the game
* MorphOS version released
* Some code cleanup at the repo
1.2.2r1 (2022-08-13)
* First release

View File

@ -65,8 +65,11 @@ $(OUT)/%.o: %.c %.h $(DEPS)
$(CC) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
%.mo: %.po
ifneq ($(shell uname), AmigaOS)
msgfmt -c -o $@ $<
endif
# cleaning everything that can be automatically recreated with "make".
clean:
$(RM) $(OBJS) $(PROG) $(LOCALE_MO)

65
makefile.mos Normal file
View File

@ -0,0 +1,65 @@
PROG = blobwarsAttrition
CC = gcc
PREFIX ?= /usr
BIN_DIR ?= $(PREFIX)/bin
DATA_DIR ?= data
LOCALE_DIR = locale
ICON_DIR = $(PREFIX)/share/icons/hicolor
DESKTOP_DIR = $(PREFIX)/share/applications
DESTDIR ?=
INST_BIN_DIR = $(DESTDIR)$(BIN_DIR)
INST_DATA_DIR = $(DESTDIR)$(DATA_DIR)
INST_LOCALE_DIR = $(DESTDIR)$(LOCALE_DIR)
INST_ICON_DIR = $(DESTDIR)$(ICON_DIR)
INST_DESKTOP_DIR = $(DESTDIR)$(DESKTOP_DIR)
SEARCHPATH += src/plat/mos
_OBJS += mosInit.o
include common.mk
CXXFLAGS += -O3 -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\" -DLOCALE_DIR=\"$(LOCALE_DIR)\" -D__USE_INLINE__
CXXFLAGS += -I/sdk/gg/usr/local/include -g -lefence
CXXFLAGS += -fms-extensions -std=gnu11 -noixemul
ifneq ("$(wildcard .errors)","")
CXXFLAGS += -Wall -Wempty-body -Werror -Wstrict-prototypes -Werror=maybe-uninitialized -Warray-bounds
endif
LDFLAGS += -noixemul -lSDL2_image -lSDL2_ttf -lfreetype -ltiff -lpng16 -ljpeg -lz -lm
LDFLAGS += -lSDL2_mixer -lmikmod -lmodplug -lFLAC -lvorbisfile -lvorbis -logg
LDFLAGS += -lSDL2 -lstdc++
SHARED_FILES = LICENSE README.md data gfx manual music sound icons
DIST_FILES = $(SHARED_FILES) locale $(PROG)
SRC_DIST_FILES = $(SHARED_FILES) src makefile* common.mk
# linking the program.
$(PROG): $(OBJS)
$(CC) -o $@ $(OBJS) $(LDFLAGS)
# prepare an archive for the program
dist:
mkdir -p release/$(PROG)-$(VERSION).$(REVISION)
cp $(PROG) release/$(PROG)-$(VERSION).$(REVISION)/
strip release/$(PROG)-$(VERSION).$(REVISION)/$(PROG)
cp icons/blob.info release/$(PROG)-$(VERSION).$(REVISION)/$(PROG).info
cp LICENSE release/$(PROG)-$(VERSION).$(REVISION)/
cp README.md release/$(PROG)-$(VERSION).$(REVISION)/
cp README-OS4.md release/$(PROG)-$(VERSION).$(REVISION)/
lha -aeqr3 a $(PROG)-$(VERSION).$(REVISION).lha release/
# prepare an archive for the program
src-dist:
$(RM) -rf $(PROG)-$(VERSION).$(REVISION)
mkdir $(PROG)-$(VERSION).$(REVISION)
cp -rL $(SRC_DIST_FILES) $(PROG)-$(VERSION).$(REVISION)
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --date=short >$(PROG)-$(VERSION).$(REVISION)/CHANGELOG.raw
tar czf $(PROG)-$(VERSION).$(REVISION).src.tar.gz $(PROG)-$(VERSION).$(REVISION)
mkdir -p dist
mv $(PROG)-$(VERSION).$(REVISION).src.tar.gz dist
$(RM) -rf $(PROG)-$(VERSION).$(REVISION)
.PHONY: dist

View File

@ -26,7 +26,7 @@ ifneq ("$(wildcard .errors)","")
CXXFLAGS += -Wall -Wempty-body -Werror -Wstrict-prototypes -Werror=maybe-uninitialized -Warray-bounds
endif
LDFLAGS += -lauto -lSDL2_image -lSDL2_ttf -lft2 -ltiff -lwebp -lpng -ljpeg -lz -lm
LDFLAGS += -lauto -lSDL2_image -lSDL2_ttf -lfreetype -ltiff -lwebp -lpng -ljpeg -lz -lm
LDFLAGS += -lSDL2_mixer -lmikmod -lmodplug -lFLAC -lsmpeg2 -lvorbisfile -lvorbis -logg
LDFLAGS += -lSDL2 -lpthread -athread=native -lstdc++
@ -38,46 +38,6 @@ SRC_DIST_FILES = $(SHARED_FILES) src makefile* common.mk
$(PROG): $(OBJS)
$(CC) -o $@ $(OBJS) $(LDFLAGS)
install:
mkdir -p $(INST_BIN_DIR)
install -m 0755 $(PROG) $(INST_BIN_DIR)
mkdir -p $(INST_DATA_DIR)
cp -r data $(INST_DATA_DIR)
cp -r gfx $(INST_DATA_DIR)
cp -r manual $(INST_DATA_DIR)
cp -r music $(INST_DATA_DIR)
cp -r sound $(INST_DATA_DIR)
mkdir -p $(INST_ICON_DIR)/16x16/apps
mkdir -p $(INST_ICON_DIR)/32x32/apps
mkdir -p $(INST_ICON_DIR)/64x64/apps
mkdir -p $(INST_ICON_DIR)/128x128/apps
cp -p icons/$(PROG)-16x16.png $(INST_ICON_DIR)/16x16/apps/$(PROG).png
cp -p icons/$(PROG)-32x32.png $(INST_ICON_DIR)/32x32/apps/$(PROG).png
cp -p icons/$(PROG)-64x64.png $(INST_ICON_DIR)/64x64/apps/$(PROG).png
cp -p icons/$(PROG)-128x128.png $(INST_ICON_DIR)/128x128/apps/$(PROG).png
mkdir -p $(INST_DESKTOP_DIR)
cp -p icons/$(PROG).desktop $(INST_DESKTOP_DIR)
@for f in $(LOCALE_MO); do \
lang=`echo $$f | sed -e 's/^locale\///;s/\.mo$$//'`; \
mkdir -p $(INST_LOCALE_DIR)/$$lang/LC_MESSAGES; \
cp -v $$f $(INST_LOCALE_DIR)/$$lang/LC_MESSAGES/$(PROG).mo; \
done
uninstall:
$(RM) $(BIN_DIR)/$(PROG)
$(RM) -rf $(DATA_DIR)
$(RM) $(ICON_DIR)/16x16/apps/$(PROG).png
$(RM) $(ICON_DIR)/32x32/apps/$(PROG).png
$(RM) $(ICON_DIR)/64x64/apps/$(PROG).png
$(RM) $(ICON_DIR)/128x128/apps/$(PROG).png
$(RM) $(DESKTOP_DIR)/$(PROG).desktop
@for f in $(LOCALE_MO); do \
lang=`echo $$f | sed -e 's/^locale\///;s/\.mo$$//'`; \
$(RM) -v $(LOCALE_DIR)/$$lang/LC_MESSAGES/$(PROG).mo; \
done
# prepare an archive for the program
dist:
mkdir -p release/$(PROG)-$(VERSION).$(REVISION)
@ -86,8 +46,8 @@ dist:
cp icons/blob.info release/$(PROG)-$(VERSION).$(REVISION)/$(PROG).info
cp LICENSE release/$(PROG)-$(VERSION).$(REVISION)/
cp README.md release/$(PROG)-$(VERSION).$(REVISION)/
cp README-OS4.md release/$(PROG)-$(VERSION).$(REVISION)/
lha -aeqr3 a $(PROG)-$(VERSION).$(REVISION).lha release/
cp README-Amiga.md release/$(PROG)-$(VERSION).$(REVISION)/
lha -aeqr3 a $(PROG)-OS4-$(VERSION).$(REVISION).lha release/
# prepare an archive for the program

View File

@ -172,9 +172,9 @@ void drawTrophies(void)
i++;
}
#if !defined(__amigaos4__) && !defined(__morphos__)
SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 255);
#endif
drawWidgets();
SDL_SetRenderTarget(app.renderer, app.backBuffer);
@ -332,7 +332,9 @@ void drawTrophyAlert(void)
blitRectRotated(atlasTexture->texture, x + 24, y + 24, &sparkle->rect, sparkleAngle);
blitRectRotated(atlasTexture->texture, x + 24, y + 24, &sparkle->rect, -sparkleAngle);
blitRectScaled(atlasTexture->texture, x, y, 48, 48, &trophyIcons[alertTrophy->value]->rect, 0);
#if !defined(__amigaos4__) && !defined(__morphos__)
SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 255);
#endif
}
}
@ -412,3 +414,4 @@ static void setSparkleColor(Trophy *t)
break;
}
}

View File

@ -450,7 +450,7 @@ static void drawMissions(void)
break;
}
}
SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 255);
}
@ -904,3 +904,4 @@ void destroyHub(void)
memset(&hubMissionHead, 0, sizeof(HubMission));
hubMissionTail = &hubMissionHead;
}

View File

@ -36,12 +36,10 @@ int main(int argc, char *argv[])
initLookups();
init18N(argc, argv);
initSDL();
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN);
init18N(argc, argv);
initGameSystem();
handleCommandLine(argc, argv);
@ -202,3 +200,4 @@ static void handleCommandLine(int argc, char *argv[])
initTitle();
}
}

101
src/plat/mos/mosInit.c Normal file
View File

@ -0,0 +1,101 @@
/*
Copyright (C) 2018-2019 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <proto/dos.h>
#include <proto/exec.h>
#include "mosInit.h"
// #define VSTRING "Blob Wars Attrition 1.2.2r1 (13.08.2022)"
// #define VERSTAG "\0$VER: " VSTRING
// static CONST_STRPTR stack USED = "$STACK:102400";
// static CONST_STRPTR version USED = VERSTAG;
static void mkpath(const char *path);
void createSaveFolder(void)
{
char *dir;
int i;
BPTR savesPathLock = Lock("PROGDIR:saves", SHARED_LOCK);
if (!savesPathLock)
{
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saves folder not found. I am going to create it.");
mkpath("PROGDIR:saves");
}
else {
UnLock(savesPathLock);
}
for (i = 0 ; i < MAX_SAVE_SLOTS ; i++)
{
dir = buildFormattedString("saves/%d", i);
mkpath(dir);
free(dir);
}
app.saveDir = "saves";
}
static void mkpath(const char *path)
{
char dir[MAX_FILENAME_LENGTH];
int i, rootPath;
strcpy(dir, "");
rootPath = 1;
for (i = 0 ; i < strlen(path) ; i++)
{
if (path[i] == '/')
{
if (!rootPath)
{
if (mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0 && errno != EEXIST)
{
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Failed to create save dir '%s'.", dir);
exit(1);
}
}
rootPath = 0;
}
dir[i] = path[i];
dir[i + 1] = '\0';
}
if (mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0 && errno != EEXIST)
{
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Failed to create save dir '%s'.", dir);
exit(1);
}
}
void createScreenshotFolder(void)
{
mkdir("PROGDIR:screenshots", S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
dev.screenshotFolder = "screenshots";
}

32
src/plat/mos/mosInit.h Normal file
View File

@ -0,0 +1,32 @@
/*
Copyright (C) 2018-2019 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/stat.h>
#include <pwd.h>
#include <unistd.h>
#include <errno.h>
#include "../../common.h"
extern char *buildFormattedString(const char *format, ...);
extern App app;
extern Dev dev;

View File

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "os4Init.h"
#define VSTRING "Blob Wars Attrition 1.2.2r1 (13.08.2022)"
#define VSTRING "Blob Wars Attrition 1.2.2r2 (19.09.2022)"
#define VERSTAG "\0$VER: " VSTRING
static CONST_STRPTR stack USED = "$STACK:102400";
static CONST_STRPTR version USED = VERSTAG;
@ -54,36 +54,6 @@ void createSaveFolder(void)
free(dir);
}
app.saveDir = "saves";
// char *userHome, *dir;
// int i;
// userHome = getenv("HOME");
// SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "User home = %s", userHome);
// if (!userHome)
// {
// SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Unable to determine user save folder.");
// exit(1);
// }
// SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "User home = %s", userHome);
// for (i = 0 ; i < MAX_SAVE_SLOTS ; i++)
// {
// dir = buildFormattedString("%s/.local/share/blobwarsAttrition/%d", userHome, i);
// mkpath(dir);
// free(dir);
// }
// app.saveDir = buildFormattedString("%s/.local/share/blobwarsAttrition", userHome);
// app.saveDir = "/save";
}
static void mkpath(const char *path)
@ -124,8 +94,8 @@ static void mkpath(const char *path)
void createScreenshotFolder(void)
{
mkdir("/tmp/blobwarsAttrition", S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
mkdir("PROGDIR:screenshots", S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
dev.screenshotFolder = "/tmp/blobwarsAttrition";
dev.screenshotFolder = "screenshots";
}

View File

@ -73,6 +73,8 @@ void initSDL(void)
printf("Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN);
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1)
{
@ -370,3 +372,4 @@ void cleanup(void)
SDL_Quit();
}

View File

@ -164,6 +164,7 @@ void drawText(int x, int y, int size, int align, SDL_Color color, const char *fo
if (app.textWidth == 0)
{
#if !defined(__amigaos4__) && !defined(__morphos__)
SDL_SetTextureColorMod(activeFont->texture, 0, 0, 0);
SDL_SetTextureAlphaMod(activeFont->texture, 255);
@ -172,11 +173,13 @@ void drawText(int x, int y, int size, int align, SDL_Color color, const char *fo
SDL_SetTextureColorMod(activeFont->texture, color.r, color.g, color.b);
SDL_SetTextureAlphaMod(activeFont->texture, color.a);
#endif
drawTextLine(x, y, size, align, drawTextBuffer);
}
else
{
#if !defined(__amigaos4__) && !defined(__morphos__)
SDL_SetTextureColorMod(activeFont->texture, 0, 0, 0);
SDL_SetTextureAlphaMod(activeFont->texture, 255);
@ -185,7 +188,8 @@ void drawText(int x, int y, int size, int align, SDL_Color color, const char *fo
SDL_SetTextureColorMod(activeFont->texture, color.r, color.g, color.b);
SDL_SetTextureAlphaMod(activeFont->texture, color.a);
#endif
drawTextLines(x, y, size, align);
}
}
@ -433,3 +437,4 @@ static char *nextCharacter(const char *str, int *i)
*i = *i + 1;
}
}

View File

@ -110,6 +110,7 @@ char *buildFormattedString(const char *format, ...)
* (Declaration that it's public domain):
* http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
*/
#if !defined(__morphos__)
char *strtok_r(char *str, const char *delim, char **nextp)
{
char *ret;
@ -139,3 +140,5 @@ char *strtok_r(char *str, const char *delim, char **nextp)
return ret;
}
#endif