Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to pntr #434

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ jobs:
- name: Build
run: make

- name: Test
run: make test
# TODO: Restore unit test framework
# - name: Test
# run: make test
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,18 @@
url = https://github.com/RobLoach/physfs.git
ignore = dirty
branch = libretro-support
[submodule "vendor/pntr"]
path = vendor/pntr
url = https://github.com/RobLoach/pntr.git
ignore = dirty
branch = master
[submodule "vendor/pntr_app"]
path = vendor/pntr_app
url = https://github.com/RobLoach/pntr_app.git
ignore = dirty
branch = master
[submodule "vendor/pntr_physfs"]
path = vendor/pntr_physfs
url = https://github.com/RobLoach/pntr_physfs.git
ignore = dirty
branch = master
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 2.0.0 - WIP
### Changed
- Moved from [sdl-libretro](https://github.com/libretro/sdl-libretro) to [pntr](https://github.com/robloach/pntr) and [pntr_app](https://github.com/robloach/pntr)

## 1.3.0 - 2024-05-11
### Fixes
- Fix playing empty ogg files through `libretro-common`, by @phcoder
Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@ clean:
test: unittest unittest-chailove
@echo "Run the testing suite by using:\n\n retroarch -L $(TARGET) test/main.chai\n\n"

vendor/noarch/noarch:
cd vendor/noarch && cmake .
@$(MAKE) -C vendor/noarch
unittest: all
@retroarch -L $(CORE_DIR)/$(TARGET) test/unittests/main.chai

unittest: vendor/noarch/noarch all
vendor/noarch/noarch $(CORE_DIR)/$(TARGET) test/unittests/main.chai

unittest-chailove: vendor/noarch/noarch all
vendor/noarch/noarch $(CORE_DIR)/$(TARGET) test/test.chailove
unittest-chailove: all
@retroarch -L $(CORE_DIR)/$(TARGET) test/test.chailove

examples: all
@retroarch -L $(TARGET) examples/benchmark/main.chai
Expand Down
108 changes: 11 additions & 97 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ SOURCES_CXX := $(wildcard \
SOURCES_S =
FLAGS += -Wfatal-errors

# random
FLAGS += -I$(CORE_DIR)/vendor/random/include
# pntr
FLAGS += -I$(CORE_DIR)/vendor/pntr
FLAGS += -I$(CORE_DIR)/vendor/pntr_app/include
FLAGS += \
-DPNTR_CUTE_PNG \
-DPNTR_ENABLE_VARGS

# pntr_physfs
FLAGS += -I$(CORE_DIR)/vendor/pntr_physfs

# libretro-common
FLAGS += -I$(CORE_DIR)/vendor/libretro-common/include \
Expand Down Expand Up @@ -47,13 +54,12 @@ ifneq ($(STATIC_LINKING), 1)
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/string/stdstring.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/time/rtime.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/vfs/vfs_implementation.c
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/compat/fopen_utf8.c
#SOURCES_C += $(CORE_DIR)/vendor/libretro-common/compat/fopen_utf8.c

# Ensure the sinc_resampler_neon is available for ARM NEON devices.
SOURCES_S += $(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/sinc_resampler_neon.S

# MD5
FLAGS += -I$(CORE_DIR)/vendor/libretro-common/include
SOURCES_C += $(CORE_DIR)/vendor/libretro-common/utils/md5.c
endif

Expand Down Expand Up @@ -94,14 +100,13 @@ FLAGS += -DWANT_ZLIB
# PhysFS
PHYSFS_DIR = $(CORE_DIR)/vendor/physfs-libretro
FLAGS += -I$(PHYSFS_DIR)/src
FLAGS += -I$(PHYSFS_DIR)/extras

FLAGS += -DPHYSFS_NO_CDROM_SUPPORT=1 \
-DPHYSFS_SUPPORTS_DEFAULT=0 \
-DPHYSFS_SUPPORTS_ZIP=1 \
-DPHYSFS_PLATFORM_LIBRETRO

SOURCES_C += $(wildcard \
$(PHYSFS_DIR)/extras/physfsrwops.c \
$(PHYSFS_DIR)/src/*.c \
)
ifeq ($(platform), osx)
Expand All @@ -112,88 +117,6 @@ ifeq ($(platform), osx)
FLAGS += -D__MACH__ -D__APPLE__
endif

# SDL_tty
FLAGS += -I$(CORE_DIR)/vendor/SDL_tty/include/SDL_tty
SOURCES_C += $(wildcard \
$(CORE_DIR)/vendor/SDL_tty/src/SDL_fnt.c \
$(CORE_DIR)/vendor/SDL_tty/src/SDL_tty.c \
)

# SDL_gfx
FLAGS += -I$(CORE_DIR)/vendor/sdl-libretro/tests/SDL_gfx-2.0.26
SOURCES_C += $(wildcard \
$(CORE_DIR)/vendor/sdl-libretro/tests/SDL_gfx-2.0.26/*.c \
)

# FreeType2
# See https://github.com/emscripten-ports/FreeType/blob/master/builds/amiga/makefile
FLAGS += -I$(CORE_DIR)/vendor/libretro-deps/freetype/include
FLAGS += -DFT2_BUILD_LIBRARY \
-DFT_USE_AUTOFIT \
-DFT_USE_RASTER \
-DFT_USE_SMOOTH \
-DFT_USE_TT \
-DFT_USE_T1 \
-DFT_USE_T42 \
-DFT_USE_T1CID \
-DFT_USE_CFF \
-DFT_USE_OTV \
-DFT_USE_GXV

SOURCES_C += \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/autofit/autofit.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftbase.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftbbox.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftbdf.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftbitmap.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftcid.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftdebug.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftfntfmt.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftfstype.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftgasp.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftglyph.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftgxval.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftinit.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftlcdfil.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftmm.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftotval.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftpatent.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftpfr.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftstroke.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftsynth.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftsystem.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/fttype1.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/base/ftwinfnt.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/bdf/bdf.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/bzip2/ftbzip2.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/cache/ftcache.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/cff/cff.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/cid/type1cid.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/gzip/ftgzip.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/lzw/ftlzw.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/pcf/pcf.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/pfr/pfr.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/psaux/psaux.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/pshinter/pshinter.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/psnames/psnames.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/raster/raster.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/sfnt/sfnt.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/smooth/smooth.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/truetype/truetype.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/type1/type1.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/type42/type42.c \
$(CORE_DIR)/vendor/libretro-deps/freetype/src/winfonts/winfnt.c

# SDL_ttf
FLAGS += -I$(CORE_DIR)/vendor/sdl-libretro/tests/SDL_ttf-2.0.11/VisualC/external/include
SOURCES_C += $(CORE_DIR)/vendor/sdl-libretro/tests/SDL_ttf-2.0.11/SDL_ttf.c

# SDL_stbimage
FLAGS += -I$(CORE_DIR)/vendor/Snippets

# STB
FLAGS += -I$(CORE_DIR)/vendor/stb

# TinySHA1
FLAGS += -I$(CORE_DIR)/vendor/TinySHA1

Expand All @@ -209,15 +132,6 @@ ifeq ($(HAVE_CHAISCRIPT),)
FLAGS += -DCHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED
endif

# SDL
ifeq ($(platform), win)
SOURCES_C += $(wildcard ./vendor/sdl-libretro/src/*.c ./vendor/sdl-libretro/src/audio/*.c ./vendor/sdl-libretro/src/cdrom/dummy/*.c ./vendor/sdl-libretro/src/cdrom/*.c ./vendor/sdl-libretro/src/cpuinfo/*.c ./vendor/sdl-libretro/src/events/*.c ./vendor/sdl-libretro/src/file/*.c ./vendor/sdl-libretro/src/stdlib/*.c ./vendor/sdl-libretro/src/thread/*.c ./vendor/sdl-libretro/src/timer/*.c ./vendor/sdl-libretro/src/video/*.c ./vendor/sdl-libretro/src/joystick/*.c ./vendor/sdl-libretro/src/video/libretro/*.c ./vendor/sdl-libretro/src/joystick/libretro/*.c ./vendor/sdl-libretro/src/timer/libretro/*.c ./vendor/sdl-libretro/src/audio/libretro/*.c ./vendor/sdl-libretro/src/thread/win32/SDL_sysmutex.c ./vendor/sdl-libretro/src/thread/win32/SDL_syssem.c ./vendor/sdl-libretro/src/thread/win32/SDL_systhread.c ./vendor/sdl-libretro/src/thread/generic/SDL_syscond.c ./vendor/sdl-libretro/src/loadso/dummy/*.c)
else
SOURCES_C += $(wildcard $(CORE_DIR)/vendor/sdl-libretro/src/*.c $(CORE_DIR)/vendor/sdl-libretro/src/audio/*.c $(CORE_DIR)/vendor/sdl-libretro/src/cdrom/dummy/*.c $(CORE_DIR)/vendor/sdl-libretro/src/cdrom/*.c $(CORE_DIR)/vendor/sdl-libretro/src/cpuinfo/*.c $(CORE_DIR)/vendor/sdl-libretro/src/events/*.c $(CORE_DIR)/vendor/sdl-libretro/src/file/*.c $(CORE_DIR)/vendor/sdl-libretro/src/stdlib/*.c $(CORE_DIR)/vendor/sdl-libretro/src/thread/*.c $(CORE_DIR)/vendor/sdl-libretro/src/timer/*.c $(CORE_DIR)/vendor/sdl-libretro/src/video/*.c $(CORE_DIR)/vendor/sdl-libretro/src/joystick/*.c $(CORE_DIR)/vendor/sdl-libretro/src/video/libretro/*.c $(CORE_DIR)/vendor/sdl-libretro/src/thread/generic/*.c $(CORE_DIR)/vendor/sdl-libretro/src/joystick/libretro/*.c $(CORE_DIR)/vendor/sdl-libretro/src/timer/libretro/*.c $(CORE_DIR)/vendor/sdl-libretro/src/audio/libretro/*.c $(CORE_DIR)/vendor/sdl-libretro/src/loadso/dummy/*.c)
endif
FLAGS += -DSDL_THREADS_DISABLED -DSDL_CDROM_DISABLED
FLAGS += -I$(CORE_DIR)/vendor/sdl-libretro/include

OBJECTS += $(SOURCES_CXX:.cpp=.o) $(SOURCES_C:.c=.o) $(SOURCES_S:.S=.o) $(SOURCES_M:.m=.o)

LDFLAGS += $(fpic) $(SHARED) $(EXTRA_LDF)
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,20 @@ make docs
The following individuals contributed to ChaiLove in some way:

- [@RobLoach](http://github.com/robloach)
- [@phcoder](https://github.com/phcoder) for the many builtbot fixes
- [@webgeek1234](http://github.com/webgeek1234) for the Android support
- [@r-type](https://github.com/r-type) for his work on [sdl-libretro](https://github.com/r-type/sdl-libretro)
- [@mudlord](https://github.com/mudlord) for his work on the [libretro-common](https://github.com/libretro/libretro-common) audio system
- [@r-type](https://github.com/r-type) for [sdl-libretro](https://github.com/r-type/sdl-libretro)
- [@mudlord](https://github.com/mudlord) for the [libretro-common](https://github.com/libretro/libretro-common) audio system
- [@orbea](http://github.com/orbea)
- [@fetzerch](http://github.com/fetzerch)
- [@bparker06](https://github.com/bparker06)
- [@twinaphex](http://github.com/twinaphex)
- [@ToKe79](https://github.com/ToKe79)
- [@konsumer](https://github.com/konsumer)
- [@baxysquare](https://github.com/baxysquare) for the [Logo](docs/chailove.png)

And many others!

## License

[MIT](COPYING)
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = "1.0.0"
PROJECT_NUMBER = "2.0.0"

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down
50 changes: 21 additions & 29 deletions src/ChaiLove.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#include "ChaiLove.h"
#include "LibretroLog.h"
#include <libretro.h>
#include <SDL.h>
#include <string>
#include "ChaiLove.h"

ChaiLove* ChaiLove::m_instance = NULL;
retro_input_state_t ChaiLove::input_state_cb = NULL;
retro_input_poll_t ChaiLove::input_poll_cb = NULL;
retro_environment_t ChaiLove::environ_cb = NULL;

void ChaiLove::destroy() {
LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Attempting to destroy ChaiLove" << std::endl;
//LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Attempting to destroy ChaiLove" << std::endl;
if (hasInstance()) {
LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Destroying ChaiLove" << std::endl;
//LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Destroying ChaiLove" << std::endl;
m_instance->quit();
delete m_instance;
m_instance = NULL;
}
LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Destroyed ChaiLove" << std::endl;
//LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Destroyed ChaiLove" << std::endl;
}

ChaiLove* ChaiLove::getInstance() {
if (!hasInstance()) {
LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Initializing ChaiLove" << std::endl;
//LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Initializing ChaiLove" << std::endl;
m_instance = new ChaiLove;
}
return m_instance;
Expand Down Expand Up @@ -56,21 +54,20 @@ void ChaiLove::quit(void) {
window.unload();
}

bool ChaiLove::load(const std::string& file, const void* data) {
bool ChaiLove::load(const std::string& file, const void* data, unsigned int dataSize) {
// Display a welcome message from ChaiLove.
#ifndef GIT_VERSION
#define GIT_VERSION ""
#endif
#ifndef GIT_VERSION
#define GIT_VERSION ""
#endif
std::string version = CHAILOVE_VERSION_STRING GIT_VERSION;
LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] ChaiLove " << version.c_str() << std::endl;
//LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] ChaiLove " << version.c_str() << std::endl;

// Iniitalize some of the initial subsystems.
sound.load();
sound.load(app);

// Initalize the file system.
bool loaded = filesystem.init(file, data);
if (!loaded) {
LibretroLog::log(RETRO_LOG_ERROR) << "[ChaiLove] [filesystem] Error loading " << file << std::endl;
if (!filesystem.init(file, data, dataSize)) {
//LibretroLog::log(RETRO_LOG_ERROR) << "[ChaiLove] [filesystem] Error loading " << file << std::endl;
return false;
}

Expand All @@ -79,7 +76,7 @@ bool ChaiLove::load(const std::string& file, const void* data) {
// Initialize the scripting system.
script = new love::script(file);
if (!script->mainLoaded) {
LibretroLog::log(RETRO_LOG_ERROR) << "[ChaiLove] [script] Error loading " << file << std::endl;
//LibretroLog::log(RETRO_LOG_ERROR) << "[ChaiLove] [script] Error loading " << file << std::endl;
return false;
}
script->conf(config);
Expand All @@ -88,12 +85,11 @@ bool ChaiLove::load(const std::string& file, const void* data) {
// Load up the window dimensions.
window.load(config);

console.load(config);
graphics.load();
image.load();
keyboard.load();
joystick.load();
math.load();
math.load(app);
mouse.load();
font.load();

Expand Down Expand Up @@ -123,7 +119,7 @@ void ChaiLove::update() {
*/
void ChaiLove::reset() {
// Tell the script that we are to reset the game.
LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Reset" << std::endl;
//LibretroLog::log(RETRO_LOG_INFO) << "[ChaiLove] Reset" << std::endl;
if (script != NULL) {
script->reset();
}
Expand All @@ -133,10 +129,6 @@ void ChaiLove::reset() {
* Render the ChaiLove.
*/
void ChaiLove::draw() {
if (event.m_shouldclose) {
return;
}

// Clear the screen.
graphics.clear();

Expand All @@ -146,13 +138,13 @@ void ChaiLove::draw() {
}

// Render the in-game console.
console.draw();
//console.draw();

// Flip the buffer.
if (SDL_Flip(screen) == -1) {
std::string out("[ChaiLove] Failed to swap the buffers: ");
LibretroLog::log(RETRO_LOG_ERROR) << out << SDL_GetError() << std::endl;
}
// if (SDL_Flip(screen) == -1) {
// std::string out("[ChaiLove] Failed to swap the buffers: ");
// //LibretroLog::log(RETRO_LOG_ERROR) << out << SDL_GetError() << std::endl;
// }
}

/**
Expand Down
Loading
Loading